Пример #1
0
        public void LoadRom(FileStream file)
        {
            byte[] tempromData = new byte[file.Length];
            file.Read(tempromData, 0, (int)file.Length);

            if (IsRomHeadered((int)file.Length))
            {
                Console.WriteLine("Header Detected");
                romData = new byte[file.Length - 0x200];
                Array.Copy(tempromData, 0x200, romData, 0, (file.Length - 0x200));
            }
            else
            {
                romData = new byte[file.Length];
                Array.Copy(tempromData, 0, romData, 0, (file.Length));
            }

            romRegion = DetectRomRegion(romData);
            //Create all gfx data in Graphics static class as 4bpp indexed format
            ZGraphics.CreateAllGfxData(romData);
            Palettes.CreateAllPalettes(romData);


            LogData.SaveToFile("Logs.txt");
            Console.WriteLine("Rom Region Detected : " + romRegion.ToString());
        }
Пример #2
0
        private void exportPalettesToASMToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AsmExporter exporter = new AsmExporter();

            exporter.richTextBox1.Text = Palettes.SavePalettesToAsm(projectForm.romManager.romData);
            exporter.ShowDialog();
        }
Пример #3
0
 public void SaveRom(FileStream file)
 {
     Palettes.SavePalettesToROM(romData);
     file.Write(romData, 0, romData.Length);
 }
Пример #4
0
        private void pictureBox1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                int p = ((e.Y / 16) * 16) + (e.X / 16);
                cd.Color = newColors[p];
                if (cd.ShowDialog() == DialogResult.OK)
                {
                    if (similarColorButton.Checked)
                    {
                        Color similarColor = newColors[p];
                        for (int i = 0; i < 256; i++)
                        {
                            if (newColors[i] == similarColor)
                            {
                                colorUndo.Add(new ColorChangedUndo((byte)p, Color.FromArgb((newColors[p].R / 8) * 8, (newColors[p].G / 8) * 8, (newColors[p].B / 8) * 8)));
                                undoRedoPosition++;
                                if (colorUndo.Count != undoRedoPosition)
                                {
                                    colorUndo.RemoveRange(undoRedoPosition, colorUndo.Count - undoRedoPosition);
                                    redoButton.Enabled = false;
                                }
                                newColors[i] = Color.FromArgb((cd.Color.R / 8) * 8, (cd.Color.G / 8) * 8, (cd.Color.B / 8) * 8);
                            }
                        }
                    }
                    else if (rampcolorButton.Checked)
                    {
                        Color rampColor = cd.Color; //selected color is always the brigther
                        Color c         = cd.Color;
                        if (colorDescription[p].linkedColor != null)
                        {
                            for (int i = 0; i < colorDescription[p].linkedColor.Length; i++)
                            {
                                c = Palettes.getColorShade(rampColor, colorDescription[colorDescription[p].linkedColor[i]].value);

                                colorUndo.Add(new ColorChangedUndo((byte)p, Color.FromArgb((newColors[p].R / 8) * 8, (newColors[p].G / 8) * 8, (newColors[p].B / 8) * 8)));
                                undoRedoPosition++;
                                newColors[colorDescription[p].linkedColor[i]] = c;
                            }
                        }


                        if (colorUndo.Count != undoRedoPosition)
                        {
                            colorUndo.RemoveRange(undoRedoPosition, colorUndo.Count - undoRedoPosition);
                            redoButton.Enabled = false;
                        }
                    }
                    else
                    {
                        colorUndo.Add(new ColorChangedUndo((byte)p, Color.FromArgb((newColors[p].R / 8) * 8, (newColors[p].G / 8) * 8, (newColors[p].B / 8) * 8)));
                        undoRedoPosition++;
                        if (colorUndo.Count != undoRedoPosition)
                        {
                            colorUndo.RemoveRange(undoRedoPosition, colorUndo.Count - undoRedoPosition);
                            redoButton.Enabled = false;
                        }
                        newColors[p] = Color.FromArgb((cd.Color.R / 8) * 8, (cd.Color.G / 8) * 8, (cd.Color.B / 8) * 8);
                    }



                    undoButton.Enabled = true;
                    pictureBox1.Refresh();
                    setTempColors();
                }
            }
        }