diff options
author | Ian C <ianc@noddybox.co.uk> | 2005-01-21 01:10:44 +0000 |
---|---|---|
committer | Ian C <ianc@noddybox.co.uk> | 2005-01-21 01:10:44 +0000 |
commit | 5b5f4849d4ada11a0f27b6da2ae0280f37eac24a (patch) | |
tree | 097c67f8825144cff93a5a2291af27d33177175c /Spectrum.cs | |
parent | 1d6e884e69dce97906df309a67fd4252f8b1dd48 (diff) |
Diffstat (limited to 'Spectrum.cs')
-rw-r--r-- | Spectrum.cs | 187 |
1 files changed, 187 insertions, 0 deletions
diff --git a/Spectrum.cs b/Spectrum.cs new file mode 100644 index 0000000..44a227c --- /dev/null +++ b/Spectrum.cs @@ -0,0 +1,187 @@ +// Base plugin for GfxEd8 +// Copyright (C) 2004 Ian Cowburn +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// $Id$ +// +using System; +using System.IO; +using GfxEdInterface; + +namespace GfxEdBasePlugin +{ + /// <summary> + /// Description of MyClass. + /// </summary> + public class Spectrum : IPlugin + { + public Spectrum() + { + m_pal=new Colour[2]; + + m_pal[0]=new Colour("Background",0x00,0x00,0x00); + m_pal[1]=new Colour("White",0xff,0xff,0xff); + + m_size=new SpriteSize[2]; + m_size[0]=new SpriteSize(8,8,1,1); + m_size[1]=new SpriteSize(16,16,1,1); + + m_paledit=new bool[2] {false,false}; + m_palcommon=new bool[2] {false,false}; + + m_config=new SpecConfigForm(); + m_output=new Output(2,1,false,false); + } + + public string Description + { + get {return "Spectrum Assembly Language (Noddybox Mono Sprites)";} + } + + public string ShortName + { + get {return "Spectrum Mono Sprites";} + } + + public string Author + { + get {return Global.Copyright;} + } + + public string URL + { + get {return Global.URL;} + } + + public uint MaxColours + { + get {return 2;} + } + + public Colour[] Palette + { + get {return m_pal;} + } + + public bool[] SprPalEditable + { + get {return m_paledit;} + } + + public bool[] SprPalCommon + { + get {return m_palcommon;} + } + + public SpriteSize[] AllowedSizes + { + get {return m_size;} + } + + public string ExportExtension + { + get {return "asm";} + } + + public bool Export(string path, SpriteList sprites) + { + if (m_config.Shift && (sprites.Count%8)!=0) + { + throw new Exception("Must be a multiple of 8 sprites to pre-shift"); + } + + TextWriter w=File.CreateText(path); + int no=0; + + foreach (Sprite s in sprites) + { + if (m_config.Shift) + { + m_output.AssemblyShifted(w,s,no); + no=(no+1)&7; + } + else + { + m_output.Assembly(w,s); + } + } + + no=0; + + if (m_config.Mask) + { + foreach (Sprite s in sprites) + { + Sprite mask=new Sprite(s); + + mask.Name+="_mask"; + + for(uint y=0;y<s.Height;y++) + { + uint x1; + uint x2; + + for(x1=0;x1<s.Width;x1++) + if (s[x1,y]==1) + break; + + for(x2=s.Width;x2>0;x2--) + if (s[x2-1,y]==1) + break; + + if (x1<s.Width && x2>0) + for(uint x=x1;x<x2;x++) + mask[x,y]=1; + } + + if (m_config.Shift) + { + m_output.AssemblyShifted(w,mask,no); + no=(no+1)&7; + } + else + { + m_output.Assembly(w,mask); + } + } + } + + w.Close(); + + return true; + } + + public IConfig Config + { + get {return m_config;} + } + + public IProcess Process + { + get {return null;} + } + + // ------------------------------------------------ + // PRIVATE + // + private Colour[] m_pal; + private SpriteSize[] m_size; + private bool[] m_paledit; + private bool[] m_palcommon; + private SpecConfigForm m_config; + private Output m_output; + } +} |