From a57e0dc5ed9a102a0b04e4a177ea9e570eeb3c8a Mon Sep 17 00:00:00 2001 From: Techokami Date: Wed, 31 Aug 2016 19:51:40 -0400 Subject: [PATCH] Added GSPalConv It converts Genesis palette data into something YY-CHR can use. --- GSPalConv.cs | 138 ++++++++++++++++++++++++++++++++++++++++++++++++++ GSPalConv.exe | Bin 0 -> 5120 bytes 2 files changed, 138 insertions(+) create mode 100644 GSPalConv.cs create mode 100644 GSPalConv.exe diff --git a/GSPalConv.cs b/GSPalConv.cs new file mode 100644 index 0000000..be04e75 --- /dev/null +++ b/GSPalConv.cs @@ -0,0 +1,138 @@ +using System; +using System.IO; + +namespace GSPalConv +{ + class Program + { + static void Main(string[] args) + { + BinaryWriter bw; + BinaryReader br; + + //Arguments stuff + if (args.Length == 0) + { + System.Console.WriteLine("Genesis Standard Palette Converter - converts 0BGR palette data into RRGGBB data, perfect for YY-CHR!"); + System.Console.WriteLine("Usage: GSPalConv [output = out.pal] [offset = 0 (give a hex value without a prefix)] [lines = 1]"); + return; + } + + //Set up the datum + string infile; + string outfile; + int offset; + int lines; + bool test = false; + byte red; + byte green; + byte blue; + byte color1; + byte color2; + + //Input file + infile = args[0]; + + //Output file + if (args.Length >= 2) + { + outfile = args[1]; + } + else + { + outfile = "out.pal"; + } + + //Palette data offset (why do some games put this data in different places? Default is for working with disassembly files) + if (args.Length >= 3) + { + offset = Int32.Parse(args[2], System.Globalization.NumberStyles.HexNumber); + } + else + { + offset = 0; + } + + //Make sure this last argument is a number... + if (args.Length >= 4) + { + test = int.TryParse(args[3], out lines); + } + else + { + lines = 1; + } + + //And if so... + if (test == true) + { + //Minimum of one palette line (like Sonic's palette from the disassembly) + if (lines < 1) + { + lines = 1; + } + //Maximum of 16 lines (YY-CHR can't handle more than that!) + else if (lines > 16) + { + lines = 16; + } + } + else + { + lines = 1; + } + + //reading from the file + try + { + br = new BinaryReader(new FileStream(infile, FileMode.Open)); + } + catch (IOException e) + { + Console.WriteLine(e.Message + "\n Cannot open input file."); + return; + } + + //create the output file + try + { + bw = new BinaryWriter(new FileStream(outfile, FileMode.Create)); + } + catch (IOException e) + { + Console.WriteLine(e.Message + "\n Cannot create output file."); + return; + } + + //The main event! + for (int i = 0; i < (lines * 16); i++) + { + color1 = br.ReadByte(); + color2 = br.ReadByte(); + // Genesis pallete entries are words - 0B GR + red = Convert.ToByte(17 * (color2 % 16)); + green = Convert.ToByte(17 * Math.Floor(color2 / 16f)); + blue = Convert.ToByte(17 * (color1 % 16)); + + //writing into the file + try + { + bw.Write(red); + bw.Write(green); + bw.Write(blue); + } + catch (IOException e) + { + Console.WriteLine(e.Message + "\n Cannot write to output file."); + return; + } + } + + //Close up everything and let user know a success was happen + br.Close(); + bw.Close(); + Console.WriteLine("SUCCESS!"); + return; + } + } +} \ No newline at end of file diff --git a/GSPalConv.exe b/GSPalConv.exe new file mode 100644 index 0000000000000000000000000000000000000000..6f458fef3d370b27306c220eca1e876bb51c32b7 GIT binary patch literal 5120 zcmeHKTWlOx8UAOyyI!xeYtL?cYf?Pkw9=-rH|yGwoYYR&x44dy*m#|!O$o{D`glF< z?94JV>v&6rjJOu0Diz`-;tj+_?L(0&H7X#4RKWwZm5_i3M2HYV1tj`}D)k}Z`_Jt9 zmI6WQ0}nmx^Pm6xxAXnyIzD^pI<*i{2=(q=qMK;BuQ)3r8;{2xYJ^^#B|4+D(AS^&#l_}m zw<%5SN{%Q7Ni>lD=`dOyHIK?fN23O~!Abnw(k3e8Tv{mqC8AFGx7{|nfeBql+y&@8P`_U)D3Pha1HF0G^JKe59v>x&H^{de0ypp&^aaHA)SPINWvdTt3li7gK% zg1QF~#QCf%EC+^Cbrm)oD~Y#5@0}2P#I^Wfl+>OZ zaXJzu_j?Le;|ON<1?q&B7)+7cdqZzQmYFbOrb2Wij6fkadmu3D&^iV?N$tCl3}=u> zEEQp!o>Z8$NUBro9L$gw?zt06X__|JDiuePTDZUSj+#np$-xNqcfz>ogn8-nFf%a^ zTQb&8xB62l(ozl6J(ynHDWX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