internal static TextMode TextModeFromTextCharMode(TextCharMode Mode) { switch (Mode) { case TextCharMode.MEGA65_ECM: return(TextMode.MEGA65_40_X_25_ECM); case TextCharMode.MEGA65_HIRES: return(TextMode.MEGA65_40_X_25_HIRES); case TextCharMode.COMMODORE_ECM: return(TextMode.COMMODORE_40_X_25_ECM); case TextCharMode.COMMODORE_HIRES: return(TextMode.COMMODORE_40_X_25_HIRES); case TextCharMode.COMMODORE_MULTICOLOR: return(TextMode.COMMODORE_40_X_25_MULTICOLOR); case TextCharMode.MEGA65_FCM: return(TextMode.MEGA65_40_X_25_FCM); case TextCharMode.MEGA65_FCM_16BIT: return(TextMode.MEGA65_40_X_25_FCM_16BIT); case TextCharMode.VIC20: return(TextMode.COMMODORE_VIC20_22_X_23); default: Debug.Log("TextModeFromTextCharMode unsupported mode " + Mode); return(TextMode.COMMODORE_40_X_25_HIRES); } }
internal static GraphicTileMode GraphicTileModeFromTextCharMode(TextCharMode Mode, int CustomColor) { switch (Mode) { case TextCharMode.COMMODORE_ECM: case TextCharMode.MEGA65_ECM: return(GraphicTileMode.COMMODORE_ECM); case TextCharMode.COMMODORE_HIRES: case TextCharMode.MEGA65_HIRES: return(GraphicTileMode.COMMODORE_HIRES); case TextCharMode.COMMODORE_MULTICOLOR: case TextCharMode.VIC20: if (CustomColor < 8) { return(GraphicTileMode.COMMODORE_HIRES); } return(GraphicTileMode.COMMODORE_MULTICOLOR); case TextCharMode.MEGA65_NCM: return(GraphicTileMode.MEGA65_NCM); case TextCharMode.MEGA65_FCM: case TextCharMode.MEGA65_FCM_16BIT: return(GraphicTileMode.MEGA65_FCM_256_COLORS); default: Debug.Log("GraphicTileModeFromTextCharMode unsupported mode " + Mode); return(GraphicTileMode.COMMODORE_HIRES); } }
public UndoCharacterEditorValuesChange(CharacterEditor Editor, CharsetProject Project) { this.Editor = Editor; this.Project = Project; Mode = Project.Mode; Colors = new ColorSettings(Project.Colors); }
public static int NumBytesOfSingleCharacter(TextCharMode Mode) { switch (Mode) { case TextCharMode.MEGA65_FCM_16BIT: return(2); default: return(1); } }
public UndoMapValueChange(MapEditor Editor, MapProject.Map Map) { MapEditor = Editor; AffectedMap = Map; AlternativeColor1 = Map.AlternativeMultiColor1; AlternativeColor2 = Map.AlternativeMultiColor2; AlternativeBGColor = Map.AlternativeBackgroundColor; AlternativeBGColor4 = Map.AlternativeBGColor4; ExtraData = Map.ExtraDataText; Name = Map.Name; TileSpacingX = Map.TileSpacingX; TileSpacingY = Map.TileSpacingY; AlternativeMode = Map.AlternativeMode; }
public static int NumBytesOfSingleCharacterBitmap(TextCharMode Mode) { switch (Mode) { case TextCharMode.COMMODORE_ECM: case TextCharMode.COMMODORE_HIRES: case TextCharMode.COMMODORE_MULTICOLOR: case TextCharMode.VIC20: return(8); case TextCharMode.MEGA65_FCM: case TextCharMode.MEGA65_FCM_16BIT: return(64); default: Debug.Log("NumBytesOfSingleCharacter unsupported Mode " + Mode); return(8); } }
public static int NumberOfColorsInCharacter(TextCharMode Mode) { switch (Mode) { case TextCharMode.COMMODORE_ECM: case TextCharMode.COMMODORE_HIRES: case TextCharMode.COMMODORE_MULTICOLOR: case TextCharMode.VIC20: return(16); case TextCharMode.MEGA65_FCM: case TextCharMode.MEGA65_FCM_16BIT: return(256); default: Debug.Log("NumberOfColorsInCharacter unsupported Mode " + Mode); return(16); } }
internal static bool RequiresCustomColorForCharacter(TextCharMode Mode) { switch (Mode) { case TextCharMode.COMMODORE_ECM: case TextCharMode.COMMODORE_HIRES: case TextCharMode.COMMODORE_MULTICOLOR: case TextCharMode.VIC20: return(true); case TextCharMode.MEGA65_FCM: case TextCharMode.MEGA65_FCM_16BIT: return(false); default: Debug.Log("RequiresCustomColorForCharacter unsupported Mode " + Mode); return(false); } }
internal static int NumCharactersForMode(TextCharMode Mode) { switch (Mode) { case TextCharMode.COMMODORE_ECM: case TextCharMode.COMMODORE_HIRES: case TextCharMode.COMMODORE_MULTICOLOR: case TextCharMode.MEGA65_FCM: case TextCharMode.VIC20: return(256); case TextCharMode.MEGA65_FCM_16BIT: return(8192); default: Debug.Log("NumCharactersForMode unsupported Mode " + Mode); return(256); } }
public static void DisplayChar(Formats.CharsetProject Charset, Palette Palette, int CharIndex, GR.Image.IImage TargetImage, int X, int Y, int AlternativeColor, int AltBGColor, int AltMColor1, int AltMColor2, int AltBGColor4, TextCharMode AlternativeMode) { Formats.CharData Char = Charset.Characters[CharIndex]; if (AlternativeMode == TextCharMode.COMMODORE_ECM) { // ECM Formats.CharData origChar = Charset.Characters[CharIndex % 64]; int bgColor = AltBGColor; switch (CharIndex / 64) { case 1: bgColor = AltMColor1; break; case 2: bgColor = AltMColor2; break; case 3: bgColor = AltBGColor4; break; } DisplayHiResChar(origChar.Tile.Data, Palette, bgColor, AlternativeColor, TargetImage, X, Y); } else if (AlternativeMode == TextCharMode.COMMODORE_MULTICOLOR) { DisplayMultiColorChar(Char.Tile.Data, Palette, AltBGColor, AltMColor1, AltMColor2, AlternativeColor, TargetImage, X, Y); } else if (AlternativeMode == TextCharMode.COMMODORE_HIRES) { DisplayHiResChar(Char.Tile.Data, Palette, AltBGColor, AlternativeColor, TargetImage, X, Y); } else if ((AlternativeMode == TextCharMode.MEGA65_FCM) || (AlternativeMode == TextCharMode.MEGA65_FCM_16BIT)) { DisplayMega65FCMChar(Char.Tile.Data, Palette, AltBGColor, AlternativeColor, TargetImage, X, Y); } else if (AlternativeMode == TextCharMode.VIC20) { DisplayVIC20Char(Char.Tile.Data, Palette, AltBGColor, AltMColor1, AltMColor2, AlternativeColor, TargetImage, X, Y); } else { Debug.Log("DisplayChar #2 unsupported mode " + AlternativeMode); } }
public bool ReadFromBuffer(GR.Memory.ByteBuffer DataIn) { if (DataIn == null) { return(false); } GR.IO.MemoryReader memIn = DataIn.MemoryReader(); uint version = memIn.ReadUInt32(); if (version == 1) { TotalNumberOfCharacters = 256; string name = memIn.ReadString(); string charsetFilename = memIn.ReadString(); for (int i = 0; i < TotalNumberOfCharacters; ++i) { Characters[i].Tile.CustomColor = memIn.ReadInt32(); } bool hasAnyMC = false; for (int i = 0; i < TotalNumberOfCharacters; ++i) { var mode = (TextCharMode)memIn.ReadUInt8(); if ((mode == TextCharMode.COMMODORE_MULTICOLOR) && (Characters[i].Tile.CustomColor < 8)) { mode = TextCharMode.COMMODORE_HIRES; } if (mode == TextCharMode.COMMODORE_MULTICOLOR) { hasAnyMC = true; } } Colors.BackgroundColor = memIn.ReadInt32(); Colors.MultiColor1 = memIn.ReadInt32(); Colors.MultiColor2 = memIn.ReadInt32(); for (int i = 0; i < TotalNumberOfCharacters; ++i) { int tileColor1 = memIn.ReadInt32(); int tileColor2 = memIn.ReadInt32(); int tileColor3 = memIn.ReadInt32(); int tileColor4 = memIn.ReadInt32(); int tileChar1 = memIn.ReadInt32(); int tileChar2 = memIn.ReadInt32(); int tileChar3 = memIn.ReadInt32(); int tileChar4 = memIn.ReadInt32(); } bool genericMulticolor = (memIn.ReadInt32() != 0); GR.Memory.ByteBuffer testbed = new GR.Memory.ByteBuffer(); memIn.ReadBlock(testbed, 64); GR.Memory.ByteBuffer charsetData = new GR.Memory.ByteBuffer(); memIn.ReadBlock(charsetData, (uint)(TotalNumberOfCharacters * 8)); for (int i = 0; i < TotalNumberOfCharacters; ++i) { Characters[i].Tile.Data = charsetData.SubBuffer(i * 8, 8); } UsedTiles = memIn.ReadUInt32(); ExportFilename = memIn.ReadString(); string exportPathBlockTable = memIn.ReadString(); string exportPathCharset = memIn.ReadString(); string exportPathEditorTiles = memIn.ReadString(); // categories Categories.Clear(); int categoryCount = memIn.ReadInt32(); for (int i = 0; i < categoryCount; ++i) { int catKey = memIn.ReadInt32(); string catName = memIn.ReadString(); Categories.Add(catName); } if (Categories.Count == 0) { // add default category Categories.Add("Uncategorized"); } for (int i = 0; i < TotalNumberOfCharacters; ++i) { Characters[i].Category = memIn.ReadInt32(); if ((Characters[i].Category < 0) || (Characters[i].Category >= Categories.Count)) { Characters[i].Category = 0; } } ExportNumCharacters = memIn.ReadInt32(); if (ExportNumCharacters < TotalNumberOfCharacters) { ExportNumCharacters = TotalNumberOfCharacters; } ShowGrid = (memIn.ReadInt32() != 0); ExportStartCharacter = memIn.ReadInt32(); Colors.BGColor4 = memIn.ReadInt32(); // playground int w = memIn.ReadInt32(); int h = memIn.ReadInt32(); if (w * h < 256) { w = 16; h = 16; } PlaygroundChars = new List <uint>(w * h); for (int i = 0; i < w * h; ++i) { ushort charInfo = memIn.ReadUInt16(); PlaygroundChars.Add((uint)((charInfo & 0xff) | ((charInfo & 0xff00) << 8))); } Mode = (TextCharMode)memIn.ReadInt32(); if (hasAnyMC) { Mode = TextCharMode.COMMODORE_MULTICOLOR; } } else if (version == 2) { Characters.Clear(); Categories.Clear(); Colors.Palettes.Clear(); TotalNumberOfCharacters = 256; Mode = TextCharMode.COMMODORE_HIRES; var chunk = new GR.IO.FileChunk(); while (chunk.ReadFromStream(memIn)) { if (chunk.Type == FileChunkConstants.CHARSET_PROJECT) { var chunkIn = chunk.MemoryReader(); var subChunk = new GR.IO.FileChunk(); while (subChunk.ReadFromStream(chunkIn)) { var subMemIn = subChunk.MemoryReader(); switch (subChunk.Type) { case FileChunkConstants.CHARSET_INFO: Mode = (TextCharMode)subMemIn.ReadInt32(); TotalNumberOfCharacters = subMemIn.ReadInt32(); ShowGrid = ((subMemIn.ReadInt32() & 1) == 1); break; case FileChunkConstants.CHARSET_COLOR_SETTINGS: Colors.BackgroundColor = subMemIn.ReadInt32(); Colors.MultiColor1 = subMemIn.ReadInt32(); Colors.MultiColor2 = subMemIn.ReadInt32(); Colors.BGColor4 = subMemIn.ReadInt32(); Colors.ActivePalette = subMemIn.ReadInt32(); break; case FileChunkConstants.PALETTE: Colors.Palettes.Add(Palette.Read(subMemIn)); break; case FileChunkConstants.CHARSET_EXPORT: ExportStartCharacter = subMemIn.ReadInt32(); ExportNumCharacters = subMemIn.ReadInt32(); ExportFilename = subMemIn.ReadString(); break; case FileChunkConstants.CHARSET_CHAR: { var charData = new CharData(); subMemIn.ReadInt32(); // was TextCharMode charData.Tile.CustomColor = subMemIn.ReadInt32(); charData.Tile.Mode = Lookup.GraphicTileModeFromTextCharMode(Mode, charData.Tile.CustomColor); charData.Category = subMemIn.ReadInt32(); int dataLength = subMemIn.ReadInt32(); charData.Tile.Data = new GR.Memory.ByteBuffer(); subMemIn.ReadBlock(charData.Tile.Data, (uint)dataLength); Characters.Add(charData); } break; case FileChunkConstants.CHARSET_CATEGORY: Categories.Add(subMemIn.ReadString()); break; case FileChunkConstants.CHARSET_PLAYGROUND: PlaygroundWidth = subMemIn.ReadInt32(); PlaygroundHeight = subMemIn.ReadInt32(); PlaygroundChars = new List <uint>(PlaygroundWidth * PlaygroundHeight); for (int i = 0; i < PlaygroundWidth * PlaygroundHeight; ++i) { // 16 bit index, 16 bit color PlaygroundChars.Add(subMemIn.ReadUInt32()); } break; } } } } if (Colors.Palettes.Count == 0) { Colors.Palettes.Add(PaletteManager.PaletteFromNumColors(Lookup.NumberOfColorsInCharacter(Mode))); } } else { return(false); } return(true); }
public static void DisplayChar(Formats.CharsetProject Charset, int CharIndex, CustomDrawControlContext Context, int AlternativeColor, int AltBGColor, int AltMColor1, int AltMColor2, int AltBGColor4, TextCharMode AlternativeMode) { Formats.CharData Char = Charset.Characters[CharIndex]; if ((AlternativeMode == TextCharMode.COMMODORE_ECM) || (AlternativeMode == TextCharMode.MEGA65_ECM)) { // ECM Formats.CharData origChar = Charset.Characters[CharIndex % 64]; int bgColor = AltBGColor; switch (CharIndex / 64) { case 1: bgColor = AltMColor1; break; case 2: bgColor = AltMColor2; break; case 3: bgColor = AltBGColor4; break; } DisplayHiResChar(origChar.Tile.Data, bgColor, AlternativeColor, Context); } else if (AlternativeMode == TextCharMode.COMMODORE_MULTICOLOR) { DisplayMultiColorChar(Char.Tile.Data, AltBGColor, AltMColor1, AltMColor2, AlternativeColor, Context); } else if ((AlternativeMode == TextCharMode.COMMODORE_HIRES) || (AlternativeMode == TextCharMode.MEGA65_HIRES)) { DisplayHiResChar(Char.Tile.Data, AltBGColor, AlternativeColor, Context); } else if ((AlternativeMode == TextCharMode.MEGA65_FCM) || (AlternativeMode == TextCharMode.MEGA65_FCM_16BIT)) { DisplayMega65FCMChar(Char.Tile.Data, AltBGColor, AlternativeColor, Context); } else if (AlternativeMode == TextCharMode.MEGA65_NCM) { DisplayMega65NCMChar(Char.Tile.Data, AltBGColor, AlternativeColor, Context); } else if (AlternativeMode == TextCharMode.VIC20) { DisplayVIC20Char(Char.Tile.Data, AltBGColor, AltMColor1, AltMColor2, AlternativeColor, Context); } else { Debug.Log("DisplayChar unsupported mode " + AlternativeMode); } }