diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..eba1110 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f652b45 --- /dev/null +++ b/.gitignore @@ -0,0 +1,299 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ +**/Properties/launchSettings.json + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Typescript v1 declaration files +typings/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..61913d1 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,16 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "(Windows) Launch", + "type": "cppvsdbg", + "request": "launch", + "program": "${workspaceRoot}/Release/PaletteCreator.exe", + "args": [], + "stopAtEntry": false, + "cwd": "${workspaceRoot}", + "environment": [], + "externalConsole": true + } + ] + } \ No newline at end of file diff --git a/App.config b/App.config new file mode 100644 index 0000000..88fa402 --- /dev/null +++ b/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Form1.Designer.cs b/Form1.Designer.cs new file mode 100644 index 0000000..3f68f07 --- /dev/null +++ b/Form1.Designer.cs @@ -0,0 +1,493 @@ +namespace PaletteCreator +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.label1 = new System.Windows.Forms.Label(); + this.pictureBox2 = new System.Windows.Forms.PictureBox(); + this.comboBox1 = new System.Windows.Forms.ComboBox(); + this.label2 = new System.Windows.Forms.Label(); + this.button1 = new System.Windows.Forms.Button(); + this.colorDialog1 = new System.Windows.Forms.ColorDialog(); + this.button3 = new System.Windows.Forms.Button(); + this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); + this.openFileDialog2 = new System.Windows.Forms.OpenFileDialog(); + this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog(); + this.button4 = new System.Windows.Forms.Button(); + this.button5 = new System.Windows.Forms.Button(); + this.button6 = new System.Windows.Forms.Button(); + this.saveFileDialog2 = new System.Windows.Forms.SaveFileDialog(); + this.saveFileDialog3 = new System.Windows.Forms.SaveFileDialog(); + this.label3 = new System.Windows.Forms.Label(); + this.button7 = new System.Windows.Forms.Button(); + this.button8 = new System.Windows.Forms.Button(); + this.openFileDialog3 = new System.Windows.Forms.OpenFileDialog(); + this.openFileDialog4 = new System.Windows.Forms.OpenFileDialog(); + this.saveFileDialog4 = new System.Windows.Forms.SaveFileDialog(); + this.button2 = new System.Windows.Forms.Button(); + this.openFileDialog5 = new System.Windows.Forms.OpenFileDialog(); + this.button9 = new System.Windows.Forms.Button(); + this.saveFileDialog5 = new System.Windows.Forms.SaveFileDialog(); + this.label4 = new System.Windows.Forms.Label(); + this.pictureBox1 = new System.Windows.Forms.PictureBox(); + this.button10 = new System.Windows.Forms.Button(); + this.label5 = new System.Windows.Forms.Label(); + this.label6 = new System.Windows.Forms.Label(); + this.label7 = new System.Windows.Forms.Label(); + this.checkBox1 = new System.Windows.Forms.CheckBox(); + this.button11 = new System.Windows.Forms.Button(); + this.openFileDialog6 = new System.Windows.Forms.OpenFileDialog(); + this.saveFileDialog6 = new System.Windows.Forms.SaveFileDialog(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(134, 9); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(85, 13); + this.label1.TabIndex = 1; + this.label1.Text = "Selected Palette"; + // + // pictureBox2 + // + this.pictureBox2.Location = new System.Drawing.Point(137, 25); + this.pictureBox2.Name = "pictureBox2"; + this.pictureBox2.Size = new System.Drawing.Size(512, 32); + this.pictureBox2.TabIndex = 2; + this.pictureBox2.TabStop = false; + this.pictureBox2.DoubleClick += new System.EventHandler(this.pictureBox2_DoubleClick); + this.pictureBox2.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.pictureBox2_MouseDoubleClick); + // + // comboBox1 + // + this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBox1.FormattingEnabled = true; + this.comboBox1.Items.AddRange(new object[] { + "Green Mail", + "Blue Mail", + "Red Mail", + "Bunny"}); + this.comboBox1.Location = new System.Drawing.Point(15, 25); + this.comboBox1.MaxDropDownItems = 4; + this.comboBox1.Name = "comboBox1"; + this.comboBox1.Size = new System.Drawing.Size(121, 21); + this.comboBox1.TabIndex = 3; + this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged); + this.comboBox1.SelectedValueChanged += new System.EventHandler(this.comboBox1_SelectedValueChanged); + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(12, 9); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(88, 13); + this.label2.TabIndex = 4; + this.label2.Text = "Selected Armor : "; + // + // button1 + // + this.button1.Location = new System.Drawing.Point(518, 539); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(190, 29); + this.button1.TabIndex = 5; + this.button1.Text = "Export All Palettes for YY-CHR"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // button3 + // + this.button3.Location = new System.Drawing.Point(518, 168); + this.button3.Name = "button3"; + this.button3.Size = new System.Drawing.Size(190, 53); + this.button3.TabIndex = 7; + this.button3.Text = "Load GFX and Palettes from ROM"; + this.button3.UseVisualStyleBackColor = true; + this.button3.Click += new System.EventHandler(this.button3_Click); + // + // openFileDialog1 + // + this.openFileDialog1.FileName = "openFileDialog1"; + this.openFileDialog1.Filter = "ROM file|*.sfc|All Files|*.*"; + this.openFileDialog1.RestoreDirectory = true; + this.openFileDialog1.FileOk += new System.ComponentModel.CancelEventHandler(this.openFileDialog1_FileOk); + // + // openFileDialog2 + // + this.openFileDialog2.FileName = "openFileDialog2"; + this.openFileDialog2.Filter = "Randomizer Sprite Format|*.spr"; + this.openFileDialog2.RestoreDirectory = true; + this.openFileDialog2.FileOk += new System.ComponentModel.CancelEventHandler(this.openFileDialog2_FileOk); + // + // saveFileDialog1 + // + this.saveFileDialog1.FileName = "YY-CHR Palette file|*.pal"; + this.saveFileDialog1.Filter = "Palettes Files|*.pal"; + this.saveFileDialog1.RestoreDirectory = true; + this.saveFileDialog1.FileOk += new System.ComponentModel.CancelEventHandler(this.saveFileDialog1_FileOk); + // + // button4 + // + this.button4.Location = new System.Drawing.Point(518, 469); + this.button4.Name = "button4"; + this.button4.Size = new System.Drawing.Size(190, 29); + this.button4.TabIndex = 8; + this.button4.Text = "Import All Palettes from YY-CHR .pal"; + this.button4.UseVisualStyleBackColor = true; + this.button4.Click += new System.EventHandler(this.button4_Click); + // + // button5 + // + this.button5.Location = new System.Drawing.Point(518, 575); + this.button5.Name = "button5"; + this.button5.Size = new System.Drawing.Size(190, 29); + this.button5.TabIndex = 9; + this.button5.Text = "Export As Sprite (for Randomizer)"; + this.button5.UseVisualStyleBackColor = true; + this.button5.Click += new System.EventHandler(this.button5_Click_1); + // + // button6 + // + this.button6.Location = new System.Drawing.Point(518, 286); + this.button6.Name = "button6"; + this.button6.Size = new System.Drawing.Size(190, 29); + this.button6.TabIndex = 10; + this.button6.Text = "Save full ROM"; + this.button6.UseVisualStyleBackColor = true; + this.button6.Click += new System.EventHandler(this.button6_Click); + // + // saveFileDialog2 + // + this.saveFileDialog2.Filter = "Randomizer Sprite Format|*.spr"; + this.saveFileDialog2.RestoreDirectory = true; + this.saveFileDialog2.FileOk += new System.ComponentModel.CancelEventHandler(this.saveFileDialog2_FileOk); + // + // saveFileDialog3 + // + this.saveFileDialog3.Filter = "Snes ROM|*.sfc"; + this.saveFileDialog3.RestoreDirectory = true; + this.saveFileDialog3.FileOk += new System.ComponentModel.CancelEventHandler(this.saveFileDialog3_FileOk); + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(12, 152); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(54, 13); + this.label3.TabIndex = 11; + this.label3.Text = "Preview : "; + // + // button7 + // + this.button7.Location = new System.Drawing.Point(518, 504); + this.button7.Name = "button7"; + this.button7.Size = new System.Drawing.Size(190, 29); + this.button7.TabIndex = 12; + this.button7.Text = "Save Selected Pal for Graphics Gale"; + this.button7.UseVisualStyleBackColor = true; + this.button7.Click += new System.EventHandler(this.button7_Click); + // + // button8 + // + this.button8.Location = new System.Drawing.Point(518, 434); + this.button8.Name = "button8"; + this.button8.Size = new System.Drawing.Size(190, 29); + this.button8.TabIndex = 13; + this.button8.Text = "Load Selected Pal from GG .pal"; + this.button8.UseVisualStyleBackColor = true; + this.button8.Click += new System.EventHandler(this.button8_Click); + // + // openFileDialog3 + // + this.openFileDialog3.FileName = "openFileDialog3"; + this.openFileDialog3.Filter = "Graphics Gale Palette|*.pal"; + this.openFileDialog3.RestoreDirectory = true; + this.openFileDialog3.FileOk += new System.ComponentModel.CancelEventHandler(this.openFileDialog3_FileOk); + // + // openFileDialog4 + // + this.openFileDialog4.FileName = "openFileDialog4"; + this.openFileDialog4.Filter = "YY-CHR Palette file|*.pal"; + this.openFileDialog4.RestoreDirectory = true; + this.openFileDialog4.FileOk += new System.ComponentModel.CancelEventHandler(this.openFileDialog4_FileOk); + // + // saveFileDialog4 + // + this.saveFileDialog4.Filter = "Graphics Gale palette|*.pal"; + this.saveFileDialog4.RestoreDirectory = true; + this.saveFileDialog4.FileOk += new System.ComponentModel.CancelEventHandler(this.saveFileDialog4_FileOk); + // + // button2 + // + this.button2.Location = new System.Drawing.Point(518, 227); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(190, 53); + this.button2.TabIndex = 14; + this.button2.Text = "Load GFX and Palettes from .spr"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click_1); + // + // openFileDialog5 + // + this.openFileDialog5.FileName = "openFileDialog1"; + this.openFileDialog5.Filter = "ROM file|*.sfc|All Files|*.*"; + this.openFileDialog5.RestoreDirectory = true; + this.openFileDialog5.FileOk += new System.ComponentModel.CancelEventHandler(this.openFileDialog5_FileOk); + // + // button9 + // + this.button9.Location = new System.Drawing.Point(518, 399); + this.button9.Name = "button9"; + this.button9.Size = new System.Drawing.Size(190, 29); + this.button9.TabIndex = 15; + this.button9.Text = "Export as Png"; + this.button9.UseVisualStyleBackColor = true; + this.button9.Click += new System.EventHandler(this.button9_Click); + // + // saveFileDialog5 + // + this.saveFileDialog5.DefaultExt = "png"; + this.saveFileDialog5.Filter = "PNG Images Files|*.png"; + this.saveFileDialog5.RestoreDirectory = true; + this.saveFileDialog5.FileOk += new System.ComponentModel.CancelEventHandler(this.saveFileDialog5_FileOk); + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(517, 9); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(49, 13); + this.label4.TabIndex = 16; + this.label4.Text = "Hands \\"; + // + // pictureBox1 + // + this.pictureBox1.Location = new System.Drawing.Point(0, 168); + this.pictureBox1.Name = "pictureBox1"; + this.pictureBox1.Size = new System.Drawing.Size(512, 448); + this.pictureBox1.TabIndex = 17; + this.pictureBox1.TabStop = false; + // + // button10 + // + this.button10.Location = new System.Drawing.Point(518, 364); + this.button10.Name = "button10"; + this.button10.Size = new System.Drawing.Size(190, 29); + this.button10.TabIndex = 18; + this.button10.Text = "Import Png"; + this.button10.UseVisualStyleBackColor = true; + this.button10.Click += new System.EventHandler(this.button10_Click); + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(101, 59); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(27, 13); + this.label5.TabIndex = 19; + this.label5.Text = "Red\r\n"; + this.label5.Visible = false; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(101, 82); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(36, 13); + this.label6.TabIndex = 20; + this.label6.Text = "Green"; + this.label6.Visible = false; + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Location = new System.Drawing.Point(101, 102); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(28, 13); + this.label7.TabIndex = 21; + this.label7.Text = "Blue"; + this.label7.Visible = false; + // + // checkBox1 + // + this.checkBox1.AutoSize = true; + this.checkBox1.Location = new System.Drawing.Point(137, 127); + this.checkBox1.Name = "checkBox1"; + this.checkBox1.Size = new System.Drawing.Size(75, 17); + this.checkBox1.TabIndex = 70; + this.checkBox1.Text = "Hex Value"; + this.checkBox1.UseVisualStyleBackColor = true; + this.checkBox1.Visible = false; + this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged); + // + // button11 + // + this.button11.Location = new System.Drawing.Point(518, 112); + this.button11.Name = "button11"; + this.button11.Size = new System.Drawing.Size(190, 53); + this.button11.TabIndex = 71; + this.button11.Text = "Load a .spr file and Patch it into a ROM"; + this.button11.UseVisualStyleBackColor = true; + this.button11.Click += new System.EventHandler(this.button11_Click); + // + // openFileDialog6 + // + this.openFileDialog6.Filter = "Randomizer Sprite Format|*.spr"; + this.openFileDialog6.FileOk += new System.ComponentModel.CancelEventHandler(this.openFileDialog6_FileOk); + // + // saveFileDialog6 + // + this.saveFileDialog6.Filter = "Snes ROM|*.sfc"; + this.saveFileDialog6.FileOk += new System.ComponentModel.CancelEventHandler(this.saveFileDialog6_FileOk); + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(720, 616); + this.Controls.Add(this.button11); + this.Controls.Add(this.checkBox1); + this.Controls.Add(this.label7); + this.Controls.Add(this.label6); + this.Controls.Add(this.label5); + this.Controls.Add(this.button10); + this.Controls.Add(this.pictureBox1); + this.Controls.Add(this.label4); + this.Controls.Add(this.button9); + this.Controls.Add(this.button2); + this.Controls.Add(this.button8); + this.Controls.Add(this.button7); + this.Controls.Add(this.label3); + this.Controls.Add(this.button6); + this.Controls.Add(this.button5); + this.Controls.Add(this.button4); + this.Controls.Add(this.button3); + this.Controls.Add(this.button1); + this.Controls.Add(this.label2); + this.Controls.Add(this.comboBox1); + this.Controls.Add(this.pictureBox2); + this.Controls.Add(this.label1); + this.Name = "Form1"; + this.Text = "Palette Creator 3.6"; + this.Load += new System.EventHandler(this.Form1_Load); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + private System.Windows.Forms.Label label1; + private System.Windows.Forms.PictureBox pictureBox2; + private System.Windows.Forms.ComboBox comboBox1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.ColorDialog colorDialog1; + private System.Windows.Forms.Button button3; + private System.Windows.Forms.OpenFileDialog openFileDialog1; + private System.Windows.Forms.OpenFileDialog openFileDialog2; + private System.Windows.Forms.SaveFileDialog saveFileDialog1; + private System.Windows.Forms.Button button4; + private System.Windows.Forms.Button button5; + private System.Windows.Forms.Button button6; + private System.Windows.Forms.SaveFileDialog saveFileDialog2; + private System.Windows.Forms.SaveFileDialog saveFileDialog3; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Button button7; + private System.Windows.Forms.Button button8; + private System.Windows.Forms.OpenFileDialog openFileDialog3; + private System.Windows.Forms.OpenFileDialog openFileDialog4; + private System.Windows.Forms.SaveFileDialog saveFileDialog4; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.OpenFileDialog openFileDialog5; + private System.Windows.Forms.Button button9; + private System.Windows.Forms.SaveFileDialog saveFileDialog5; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.PictureBox pictureBox1; + private System.Windows.Forms.Button button10; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.TextBox r1; + private System.Windows.Forms.TextBox g1; + private System.Windows.Forms.TextBox b1; + private System.Windows.Forms.TextBox r2; + private System.Windows.Forms.TextBox g2; + private System.Windows.Forms.TextBox b2; + private System.Windows.Forms.TextBox b3; + private System.Windows.Forms.TextBox g3; + private System.Windows.Forms.TextBox r3; + private System.Windows.Forms.TextBox b4; + private System.Windows.Forms.TextBox g4; + private System.Windows.Forms.TextBox r4; + private System.Windows.Forms.TextBox b5; + private System.Windows.Forms.TextBox g5; + private System.Windows.Forms.TextBox r5; + private System.Windows.Forms.TextBox b6; + private System.Windows.Forms.TextBox g6; + private System.Windows.Forms.TextBox r6; + private System.Windows.Forms.TextBox b7; + private System.Windows.Forms.TextBox g7; + private System.Windows.Forms.TextBox r7; + private System.Windows.Forms.TextBox b8; + private System.Windows.Forms.TextBox g8; + private System.Windows.Forms.TextBox r8; + private System.Windows.Forms.TextBox b9; + private System.Windows.Forms.TextBox g9; + private System.Windows.Forms.TextBox r9; + private System.Windows.Forms.TextBox b10; + private System.Windows.Forms.TextBox g10; + private System.Windows.Forms.TextBox r10; + private System.Windows.Forms.TextBox b11; + private System.Windows.Forms.TextBox g11; + private System.Windows.Forms.TextBox r11; + private System.Windows.Forms.TextBox b12; + private System.Windows.Forms.TextBox g12; + private System.Windows.Forms.TextBox r12; + private System.Windows.Forms.TextBox b13; + private System.Windows.Forms.TextBox g13; + private System.Windows.Forms.TextBox r13; + private System.Windows.Forms.TextBox b14; + private System.Windows.Forms.TextBox g14; + private System.Windows.Forms.TextBox r14; + private System.Windows.Forms.TextBox b15; + private System.Windows.Forms.TextBox g15; + private System.Windows.Forms.TextBox r15; + private System.Windows.Forms.TextBox b16; + private System.Windows.Forms.TextBox g16; + private System.Windows.Forms.TextBox r16; + private System.Windows.Forms.CheckBox checkBox1; + private System.Windows.Forms.Button button11; + private System.Windows.Forms.OpenFileDialog openFileDialog6; + private System.Windows.Forms.SaveFileDialog saveFileDialog6; + } +} + diff --git a/Form1.cs b/Form1.cs new file mode 100644 index 0000000..4d1bd2a --- /dev/null +++ b/Form1.cs @@ -0,0 +1,869 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using System.IO; +using System.Drawing.Imaging; +using System.Runtime.InteropServices; + +namespace PaletteCreator +{ + public partial class Form1 : Form + { + public Form1() + { + InitializeComponent(); + } + Color[] palette = new Color[17]; + Color[] palette2 = new Color[17]; + Color[] palette3 = new Color[17]; + Color[] palette4 = new Color[17]; + string[] tempFolders = new string[10]; + private void Form1_Load(object sender, EventArgs e) + { + + /* if (File.Exists("folderstemp.txt")) + { + tempFolders = File.ReadAllLines("folderstemp.txt"); + openFileDialog1.InitialDirectory = tempFolders[0]; + openFileDialog2.InitialDirectory = tempFolders[1]; + openFileDialog3.InitialDirectory = tempFolders[2]; + openFileDialog4.InitialDirectory = tempFolders[3]; + openFileDialog5.InitialDirectory = tempFolders[4]; + saveFileDialog1.InitialDirectory = tempFolders[5]; + saveFileDialog2.InitialDirectory = tempFolders[6]; + saveFileDialog3.InitialDirectory = tempFolders[7]; + saveFileDialog4.InitialDirectory = tempFolders[8]; + saveFileDialog5.InitialDirectory = tempFolders[9]; + }*/ + + for (int i = 0; i < 16; i++) + { + palette[i] = Color.FromArgb(i * 15, i * 15, i * 15); + palette2[i] = Color.FromArgb(i * 15, i * 15, i * 15); + palette3[i] = Color.FromArgb(i * 15, i * 15, i * 15); + palette4[i] = Color.FromArgb(i * 15, i * 15, i * 15); + } + pictureBox1.Image = new Bitmap(512, 1024); + data = new byte[0x7000];/* + FileStream fs = new FileStream("sprites/zelda.spr", FileMode.OpenOrCreate, FileAccess.Read); + fs.Read(data, 0, 0x7000); + fs.Close();*/ + + refreshEverything(); + + comboBox1.SelectedIndex = 0; + + } + + public void refreshEverything() + { + + pictureBox2.Image = new Bitmap(512, 32); + Graphics g = Graphics.FromImage(pictureBox2.Image); + for (int i = 0; i < 16; i++) + { + if (comboBox1.SelectedIndex == 0) + g.FillRectangle(new SolidBrush(palette[i]), new Rectangle(i * 32, 0, (i * 32) + 32, 32)); + if (comboBox1.SelectedIndex == 1) + g.FillRectangle(new SolidBrush(palette2[i]), new Rectangle(i * 32, 0, (i * 32) + 32, 32)); + if (comboBox1.SelectedIndex == 2) + g.FillRectangle(new SolidBrush(palette3[i]), new Rectangle(i * 32, 0, (i * 32) + 32, 32)); + if (comboBox1.SelectedIndex == 3) + g.FillRectangle(new SolidBrush(palette4[i]), new Rectangle(i * 32, 0, (i * 32) + 32, 32)); + } + + + + for (int i = 0; i < 14; i++) + { + load4bpp(i); + updateGraphic(i); + } + //; + //updateGraphic(i); + + //Graphics gp = Graphics.FromImage(pictureBox1.Image); + //gp.Clear(Color.Black); + + + } + + byte[,] imgdata = new byte[128, 32]; + + byte[] data; + int[] positions = new int[] { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 }; + int hexOffset = 0x0; + public void load4bpp(int pos = 0) + { + + for (int j = 0; j < 4; j++) //4 par y + { + for (int i = 0; i < 16; i++) + { + int offset = (hexOffset + (pos * 0x800)) + ((j * 32) * 16) + (i * 32); + for (int x = 0; x < 8; x++) + { + for (int y = 0; y < 8; y++) + { + byte tmpbyte = 0; + + if ((data[offset + (x * 2)] & positions[y]) == positions[y]) + { + tmpbyte += 1; + } + if ((data[offset + (x * 2) + 1] & positions[y]) == positions[y]) + { + tmpbyte += 2; + } + + if ((data[offset + 16 + (x * 2)] & positions[y]) == positions[y]) + { + tmpbyte += 4; + } + if ((data[offset + 16 + (x * 2) + 1] & positions[y]) == positions[y]) + { + tmpbyte += 8; + } + + imgdata[y + (i * 8), x + (j * 8)] = tmpbyte; + + } + } + // pos++; + } + } + + + } + + + + + /* public void load4bpp(int pos = 0) + { + + for (int j = 0; j < 4; j++) //4 par y + { + for (int i = 0; i < 16; i++) + { + int offset = (hexOffset + (pos * 0x800)) + ((j * 32) * 16) + (i * 32); + for (int x = 0; x < 8; x++) + { + for (int y = 0; y < 8; y++) + { + byte tmpbyte = 0; + + if ((data[offset + (x * 2)] & positions[y]) == positions[y]) + { + tmpbyte += 1; + } + if ((data[offset + (x * 2) + 1] & positions[y]) == positions[y]) + { + tmpbyte += 2; + } + + if ((data[offset + 16 + (x * 2)] & positions[y]) == positions[y]) + { + tmpbyte += 4; + } + if ((data[offset + 16 + (x * 2) + 1] & positions[y]) == positions[y]) + { + tmpbyte += 8; + } + + imgdata[y + (i * 8), x + (j * 8)] = tmpbyte; + + } + } + // pos++; + } + } + + + }*/ + + + Bitmap loadedblocks = new Bitmap(128, 32); + byte[] bitmap_data = new byte[4096 * 3]; + public void updateGraphic(int pos) + { + + Graphics g = Graphics.FromImage(pictureBox1.Image); + g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor; + g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None; + int bitmap_pos = 0; + + for (int y = 0; y < 32; y++) + { + for (int x = 0; x < 128; x++) + { + + bitmap_data[bitmap_pos] = imgdata[x, y]; + bitmap_data[bitmap_pos + 1] = imgdata[x, y]; + bitmap_data[bitmap_pos + 2] = imgdata[x, y]; + bitmap_pos += 3; + + /*if (comboBox1.SelectedIndex == 1) + { + bitmap_data[bitmap_pos] = palette2[imgdata[x, y]].B; + bitmap_data[bitmap_pos + 1] = palette2[imgdata[x, y]].G; + bitmap_data[bitmap_pos + 2] = palette2[imgdata[x, y]].R; + bitmap_pos += 3; + } + if (comboBox1.SelectedIndex == 2) + { + bitmap_data[bitmap_pos] = palette3[imgdata[x, y]].B; + bitmap_data[bitmap_pos + 1] = palette3[imgdata[x, y]].G; + bitmap_data[bitmap_pos + 2] = palette3[imgdata[x, y]].R; + bitmap_pos += 3; + } + if (comboBox1.SelectedIndex == 3) + { + bitmap_data[bitmap_pos] = palette4[imgdata[x, y]].B; + bitmap_data[bitmap_pos + 1] = palette4[imgdata[x, y]].G; + bitmap_data[bitmap_pos + 2] = palette4[imgdata[x, y]].R; + bitmap_pos += 3; + }*/ + } + } + // + Graphics gx = Graphics.FromImage(loadedblocks); + gx.Clear(Color.Black); + ProcessUsingLockbits((Bitmap)loadedblocks); + //g.FillRectangle(Brushes.Fuchsia, new Rectangle(0, pos * 32, 128, 32)); + if (pos >= 7) + { + g.DrawImage(loadedblocks, new Rectangle(255, (pos-7) * 63, 256, 64), 0, 0, 128, 32, GraphicsUnit.Pixel); + } + else + { + g.DrawImage(loadedblocks, new Rectangle(0, pos * 63, 256, 64), 0, 0, 128, 32, GraphicsUnit.Pixel); + } + + + pictureBox1.Refresh(); + } + + private void pictureBox2_DoubleClick(object sender, EventArgs e) + { + + } + + private void pictureBox2_MouseDoubleClick(object sender, MouseEventArgs e) + { + for (int i = 0; i < 16; i++) + { + if (e.X>=i*32 && e.X <= (i*32)+32) + { + if (comboBox1.SelectedIndex == 0) + { + colorDialog1.Color = palette[i]; + colorDialog1.ShowDialog(); + palette[i] = colorDialog1.Color; + } + if (comboBox1.SelectedIndex == 1) + { + colorDialog1.Color = palette2[i]; + colorDialog1.ShowDialog(); + palette2[i] = colorDialog1.Color; + } + if (comboBox1.SelectedIndex == 2) + { + colorDialog1.Color = palette3[i]; + colorDialog1.ShowDialog(); + palette3[i] = colorDialog1.Color; + } + if (comboBox1.SelectedIndex == 3) + { + colorDialog1.Color = palette4[i]; + colorDialog1.ShowDialog(); + palette4[i] = colorDialog1.Color; + } + } + } + refreshEverything(); + } + + private void button3_Click(object sender, EventArgs e) + { + if (tempFolders[0] != null) + { + openFileDialog1.InitialDirectory = tempFolders[0]; + } + + openFileDialog1.ShowDialog(); + + } + + public Color getColor(short c) + { + return Color.FromArgb(((c & 0x1F) * 8), ((c & 0x3E0) >> 5)*8, ((c & 0x7C00) >> 10) * 8); + } + byte[] ROM_DATA; + private void openFileDialog1_FileOk(object sender, CancelEventArgs e) + { + + tempFolders[0] = Path.GetDirectoryName(openFileDialog1.FileName); + FileStream fs = new FileStream(openFileDialog1.FileName, FileMode.Open, FileAccess.Read); + ROM_DATA = new byte[(int)fs.Length]; + fs.Read(ROM_DATA, 0, (int)fs.Length); + + fs.Close(); + data = new byte[0x7000]; + for (int i = 0;i<0x7000;i++) + { + data[i] = ROM_DATA[0x80000 + i]; + } + + //palettes[0] = new Palette(0x0DD308, 15); + //palettes[1] = new Palette(0x0DD326, 15); + //palettes[2] = new Palette(0x0DD344, 15); + for (int i = 0;i<15;i++) + { + palette[i+1] = getColor((short)((ROM_DATA[0x0DD308 + (i * 2)+1] << 8) + (ROM_DATA[0x0DD308 + (i * 2)]))); + palette2[i + 1] = getColor((short)((ROM_DATA[0x0DD326 + (i * 2) + 1] << 8) + (ROM_DATA[0x0DD326 + (i * 2)]))); + palette3[i + 1] = getColor((short)((ROM_DATA[0x0DD344 + (i * 2) + 1] << 8) + (ROM_DATA[0x0DD344 + (i * 2)]))); + palette4[i + 1] = getColor((short)((ROM_DATA[0x0DD362 + (i * 2) + 1] << 8) + (ROM_DATA[0x0DD362 + (i * 2)]))); + } + refreshEverything(); + + } + + private void button2_Click(object sender, EventArgs e) + { + openFileDialog2.ShowDialog(); + } + + private void openFileDialog2_FileOk(object sender, CancelEventArgs e) + { + tempFolders[1] = Path.GetDirectoryName(openFileDialog2.FileName); + ROM_DATA = new byte[2097152]; + FileStream fs = new FileStream(openFileDialog2.FileName, FileMode.Open, FileAccess.Read); + data = new byte[fs.Length]; + fs.Read(data, 0, (int)fs.Length); + + + + if (fs.Length == 0x7078) + { + for(int i = 0;i<0x7000;i++) + { + ROM_DATA[0x80000+i] = data[i]; + } + + + for (int i = 0; i < 15; i++) + { + palette[i + 1] = getColor((short)((data[0x7000 + (i * 2) + 1] << 8) + (data[0x7000 + (i * 2)]))); + } + for (int i = 0; i < 15; i++) + { + palette2[i + 1] = getColor((short)((data[0x7000 + 30 + (i * 2) + 1] << 8) + (data[0x7000 + 30 + (i * 2)]))); + } + for (int i = 0; i < 15; i++) + { + palette3[i + 1] = getColor((short)((data[0x7000 + 60 + (i * 2) + 1] << 8) + (data[0x7000 + 60 + (i * 2)]))); + } + for (int i = 0; i < 15; i++) + { + palette4[i + 1] = getColor((short)((data[0x7000 + 90 + (i * 2) + 1] << 8) + (data[0x7000 + 90 + (i * 2)]))); + } + } + else + { + //not sprite format + MessageBox.Show("Unknown file format !"); + } + + + fs.Close(); + refreshEverything(); + } + + private void button1_Click(object sender, EventArgs e) + { + if (tempFolders[5] != null) + { + saveFileDialog1.InitialDirectory = tempFolders[5]; + } + saveFileDialog1.ShowDialog(); + } + + private void saveFileDialog1_FileOk(object sender, CancelEventArgs e) + { + tempFolders[5] = Path.GetDirectoryName(saveFileDialog1.FileName); + + byte[] palette_data = new byte[0x300]; + int palette_data_i = 0; + for (int i = 0; i < 16; i++) + { + palette_data[palette_data_i] = palette[i].R; + palette_data[palette_data_i + 1] = palette[i].G; + palette_data[palette_data_i + 2] = palette[i].B; + palette_data_i += 3; + } + for (int i = 0; i < 16; i++) + { + palette_data[palette_data_i] = palette2[i].R; + palette_data[palette_data_i + 1] = palette2[i].G; + palette_data[palette_data_i + 2] = palette2[i].B; + palette_data_i += 3; + } + for (int i = 0; i < 16; i++) + { + palette_data[palette_data_i] = palette3[i].R; + palette_data[palette_data_i + 1] = palette3[i].G; + palette_data[palette_data_i + 2] = palette3[i].B; + palette_data_i += 3; + } + for (int i = 0; i < 16; i++) + { + palette_data[palette_data_i] = palette4[i].R; + palette_data[palette_data_i + 1] = palette4[i].G; + palette_data[palette_data_i + 2] = palette4[i].B; + palette_data_i += 3; + } + + FileStream fs = new FileStream(saveFileDialog1.FileName, FileMode.OpenOrCreate, FileAccess.Write); + fs.Write(palette_data, 0, 0x300); + fs.Close(); + } + + private void button4_Click(object sender, EventArgs e) + { + if (tempFolders[3] != null) + { + openFileDialog4.InitialDirectory = tempFolders[3]; + } + openFileDialog4.ShowDialog(); + } + + private void comboBox1_SelectedValueChanged(object sender, EventArgs e) + { + + } + + private void button5_Click(object sender, EventArgs e) + { + + } + + private void saveFileDialog2_FileOk(object sender, CancelEventArgs e) + { + tempFolders[6] = Path.GetDirectoryName(saveFileDialog2.FileName); + + if (ROM_DATA != null) + { + byte[] palette_data = new byte[0x78]; + int palette_data_i = 0; + for (int i = 0; i < 15; i++) + { + short s = (short)(((palette[i + 1].B / 8) << 10) | ((palette[i + 1].G / 8) << 5) | ((palette[i + 1].R / 8))); + palette_data[palette_data_i] = (byte)(s & 0x00FF); + palette_data[palette_data_i + 1] = (byte)((s >> 8) & 0x00FF); + palette_data_i += 2; + } + for (int i = 0; i < 15; i++) + { + short s = (short)(((palette2[i + 1].B / 8) << 10) | ((palette2[i + 1].G / 8) << 5) | ((palette2[i + 1].R / 8))); + palette_data[palette_data_i] = (byte)(s & 0x00FF); + palette_data[palette_data_i + 1] = (byte)((s >> 8) & 0x00FF); + palette_data_i += 2; + } + for (int i = 0; i < 15; i++) + { + short s = (short)(((palette3[i + 1].B / 8) << 10) | ((palette3[i + 1].G / 8) << 5) | ((palette3[i + 1].R / 8))); + palette_data[palette_data_i] = (byte)(s & 0x00FF); + palette_data[palette_data_i + 1] = (byte)((s >> 8) & 0x00FF); + palette_data_i += 2; + } + for (int i = 0; i < 15; i++) + { + short s = (short)(((palette4[i + 1].B / 8) << 10) | ((palette4[i + 1].G / 8) << 5) | ((palette4[i + 1].R / 8))); + palette_data[palette_data_i] = (byte)(s & 0x00FF); + palette_data[palette_data_i + 1] = (byte)((s >> 8) & 0x00FF); + palette_data_i += 2; + } + data = new byte[0x7000 + 0x78]; + for (int i = 0;i<0x7000;i++) + { + data[i] = ROM_DATA[0x80000 + i]; + } + for (int i = 0; i < 0x78; i++) + { + data[0x7000+i] = palette_data[i]; + } + + FileStream fs = new FileStream(saveFileDialog2.FileName, FileMode.OpenOrCreate, FileAccess.Write); + fs.Write(data, 0, 0x7000 + 0x78); + fs.Close(); + } + } + + private void saveFileDialog3_FileOk(object sender, CancelEventArgs e) + { + tempFolders[7] = Path.GetDirectoryName(saveFileDialog3.FileName); + if (ROM_DATA != null) + { + byte[] palette_data = new byte[0x78]; + int palette_data_i = 0; + for (int i = 0; i < 15; i++) + { + short s = (short)(((palette[i + 1].B / 8) << 10) | ((palette[i + 1].G / 8) << 5) | ((palette[i + 1].R / 8))); + palette_data[palette_data_i] = (byte)(s & 0x00FF); + palette_data[palette_data_i + 1] = (byte)((s >> 8) & 0x00FF); + palette_data_i += 2; + } + for (int i = 0; i < 15; i++) + { + short s = (short)(((palette2[i + 1].B / 8) << 10) | ((palette2[i + 1].G / 8) << 5) | ((palette2[i + 1].R / 8))); + palette_data[palette_data_i] = (byte)(s & 0x00FF); + palette_data[palette_data_i + 1] = (byte)((s >> 8) & 0x00FF); + palette_data_i += 2; + } + for (int i = 0; i < 15; i++) + { + short s = (short)(((palette3[i + 1].B / 8) << 10) | ((palette3[i + 1].G / 8) << 5) | ((palette3[i + 1].R / 8))); + palette_data[palette_data_i] = (byte)(s & 0x00FF); + palette_data[palette_data_i + 1] = (byte)((s >> 8) & 0x00FF); + palette_data_i += 2; + } + for (int i = 0; i < 15; i++) + { + short s = (short)(((palette4[i + 1].B / 8) << 10) | ((palette4[i + 1].G / 8) << 5) | ((palette4[i + 1].R / 8))); + palette_data[palette_data_i] = (byte)(s & 0x00FF); + palette_data[palette_data_i + 1] = (byte)((s >> 8) & 0x00FF); + palette_data_i += 2; + } + data = new byte[0x7000 + 0x78]; + for (int i = 0; i < 0x7000; i++) + { + //data[i] = ROM_DATA[0x80000 + i]; + } + for (int i = 0; i < 120; i++) + { + ROM_DATA[0x0DD308+i] = palette_data[i]; + } + + FileStream fs = new FileStream(saveFileDialog3.FileName, FileMode.OpenOrCreate, FileAccess.Write); + fs.Write(ROM_DATA, 0, ROM_DATA.Length); + fs.Close(); + } + } + + private void button5_Click_1(object sender, EventArgs e) + { + if (tempFolders[6] != null) + { + saveFileDialog2.InitialDirectory = tempFolders[6]; + } + saveFileDialog2.ShowDialog(); + } + + private void button6_Click(object sender, EventArgs e) + { + if (tempFolders[7] != null) + { + saveFileDialog3.InitialDirectory = tempFolders[7]; + } + saveFileDialog3.ShowDialog(); + } + + private void button8_Click(object sender, EventArgs e) + { + if (tempFolders[2] != null) + { + openFileDialog3.InitialDirectory = tempFolders[2]; + } + openFileDialog3.ShowDialog(); + } + + private void openFileDialog4_FileOk(object sender, CancelEventArgs e) + { + tempFolders[3] = Path.GetDirectoryName(openFileDialog4.FileName); + File.WriteAllLines("folderstemp.txt", tempFolders); + byte[] palette_data = new byte[0x300]; + FileStream fs = new FileStream(openFileDialog4.FileName, FileMode.OpenOrCreate, FileAccess.Read); + fs.Read(palette_data, 0, 0x300); + fs.Close(); + + + int palette_data_i = 0; + for (int i = 0; i < 16; i++) + { + palette[i] = Color.FromArgb(((palette_data[palette_data_i]/8)*8), ((palette_data[palette_data_i+1]/8)*8), ((palette_data[palette_data_i+2]/8)*8)); + palette_data_i += 3; + } + for (int i = 0; i < 16; i++) + { + palette2[i] = Color.FromArgb(((palette_data[palette_data_i]/8)*8), ((palette_data[palette_data_i + 1]/8)*8), ((palette_data[palette_data_i + 2]/8)*8)); + palette_data_i += 3; + } + for (int i = 0; i < 16; i++) + { + palette3[i] = Color.FromArgb(((palette_data[palette_data_i]/8)*8), ((palette_data[palette_data_i + 1]/8)*8), ((palette_data[palette_data_i + 2]/8)*8)); + palette_data_i += 3; + } + for (int i = 0; i < 16; i++) + { + palette4[i] = Color.FromArgb(((palette_data[palette_data_i]/8)*8), ((palette_data[palette_data_i + 1]/8)*8), ((palette_data[palette_data_i + 2]/8)*8)); + palette_data_i += 3; + } + refreshEverything(); + + } + + private void openFileDialog3_FileOk(object sender, CancelEventArgs e) + { + //Graphics Gale Palette load + tempFolders[2] = Path.GetDirectoryName(openFileDialog3.FileName); + string[] text = File.ReadAllLines(openFileDialog3.FileName); + for(int i = 3;i<19;i++) + { + string[] colorstring = text[i].Split(' '); + int R; + int G; + int B; + Int32.TryParse(colorstring[0], out R); + Int32.TryParse(colorstring[1], out G); + Int32.TryParse(colorstring[2], out B); + if (comboBox1.SelectedIndex == 0) + { + palette[i-3] = Color.FromArgb(((R/16)*16),((G / 16) * 16),((B / 16) * 16)); + } + if (comboBox1.SelectedIndex == 1) + { + palette2[i-3] = Color.FromArgb(((R / 16) * 16), ((G / 16) * 16), ((B / 16) * 16)); + } + if (comboBox1.SelectedIndex == 2) + { + palette3[i-3] = Color.FromArgb(((R / 16) * 16), ((G / 16) * 16), ((B / 16) * 16)); + } + if (comboBox1.SelectedIndex == 3) + { + palette4[i-3] = Color.FromArgb(((R / 16) * 16), ((G / 16) * 16), ((B / 16) * 16)); + } + + } + refreshEverything(); + + + } + + private void button7_Click(object sender, EventArgs e) + { + if (tempFolders[8] != null) + { + saveFileDialog4.InitialDirectory = tempFolders[8]; + } + saveFileDialog4.ShowDialog(); + } + + private void saveFileDialog4_FileOk(object sender, CancelEventArgs e) + { + tempFolders[8] = Path.GetDirectoryName(saveFileDialog4.FileName); + + string text = "JASC-PAL\n0100\n16\n"; + + for (int i = 0; i < 16; i++) + { + if (comboBox1.SelectedIndex == 0) + { + text += palette[i].R.ToString() + " " + palette[i].G.ToString() + " " + palette[i].B.ToString() + "\n"; + } + if (comboBox1.SelectedIndex == 1) + { + text += palette2[i].R.ToString() + " " + palette2[i].G.ToString() + " " + palette2[i].B.ToString() + "\n"; + } + if (comboBox1.SelectedIndex == 2) + { + text += palette3[i].R.ToString() + " " + palette3[i].G.ToString() + " " + palette3[i].B.ToString() + "\n"; + } + if (comboBox1.SelectedIndex == 3) + { + text += palette4[i].R.ToString() + " " + palette4[i].G.ToString() + " " + palette4[i].B.ToString() + "\n"; + } + + } + File.WriteAllText(saveFileDialog4.FileName, text); + } + + private void button2_Click_1(object sender, EventArgs e) + { + if (tempFolders[1] != null) + { + openFileDialog2.InitialDirectory = tempFolders[1]; + } + openFileDialog2.ShowDialog(); + + } + + private void button9_Click(object sender, EventArgs e) + { + if (tempFolders[9] != null) + { + saveFileDialog5.InitialDirectory = tempFolders[9]; + } + saveFileDialog5.ShowDialog(); + } + + private void saveFileDialog5_FileOk(object sender, CancelEventArgs e) + { + tempFolders[9] = Path.GetDirectoryName(saveFileDialog5.FileName); + Bitmap tempBitmap = new Bitmap(128, 448); + Graphics gg = Graphics.FromImage(tempBitmap); + for (int i = 0; i < 14; i++) + { + load4bpp(i); + updateGraphic(i); + gg.DrawImage(loadedblocks, new Rectangle(0, i * 32, 128, 32), 0, 0, 128, 32, GraphicsUnit.Pixel); + } + tempBitmap.Save(saveFileDialog5.FileName, System.Drawing.Imaging.ImageFormat.Png); + } + + + private void ProcessUsingLockbits(Bitmap processedBitmap) + { + BitmapData bitmapData = processedBitmap.LockBits(new Rectangle(0, 0, processedBitmap.Width, processedBitmap.Height), ImageLockMode.ReadWrite, processedBitmap.PixelFormat); + + int bytesPerPixel = Bitmap.GetPixelFormatSize(processedBitmap.PixelFormat) / 8; + int byteCount = bitmapData.Stride * processedBitmap.Height; + byte[] pixels = new byte[byteCount]; + IntPtr ptrFirstPixel = bitmapData.Scan0; + Marshal.Copy(ptrFirstPixel, pixels, 0, pixels.Length); + int heightInPixels = bitmapData.Height; + int widthInBytes = bitmapData.Width * bytesPerPixel; + int pix = 0; + for (int y = 0; y < heightInPixels; y++) + { + byte blue = 0; + int currentLine = y * bitmapData.Stride; + for (int x = 0; x < widthInBytes; x = x + bytesPerPixel) + { + // calculate new pixel value + if (selected_palette == 0) + { + pixels[currentLine + x] = palette[bitmap_data[pix]].B; + pixels[currentLine + x + 1] = palette[bitmap_data[pix+1]].G; + pixels[currentLine + x + 2] = palette[bitmap_data[pix+2]].R; + } + else if (selected_palette == 1) + { + pixels[currentLine + x] = palette2[bitmap_data[pix]].B; + pixels[currentLine + x + 1] = palette2[bitmap_data[pix + 1]].G; + pixels[currentLine + x + 2] = palette2[bitmap_data[pix + 2]].R; + } + else if (selected_palette == 2) + { + pixels[currentLine + x] = palette3[bitmap_data[pix]].B; + pixels[currentLine + x + 1] = palette3[bitmap_data[pix + 1]].G; + pixels[currentLine + x + 2] = palette3[bitmap_data[pix + 2]].R; + } + else if (selected_palette == 3) + { + pixels[currentLine + x] = palette4[bitmap_data[pix]].B; + pixels[currentLine + x + 1] = palette4[bitmap_data[pix + 1]].G; + pixels[currentLine + x + 2] = palette4[bitmap_data[pix + 2]].R; + } + + pix += 3; + //Console.Write(currentLine + ","); + /*pixels[currentLine + x] = blue; + pixels[currentLine + x + 1] = blue; + pixels[currentLine + x + 2] = blue; + blue++;*/ + } + + } + + // copy modified bytes back + Marshal.Copy(pixels, 0, ptrFirstPixel, pixels.Length); + processedBitmap.UnlockBits(bitmapData); + } + int selected_palette = 0; + private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) + { + if (comboBox1.SelectedIndex == 0) + { + label4.Text = "Hands \\"; + selected_palette = 0; + } + if (comboBox1.SelectedIndex == 1) + { + label4.Text = "Gloves \\"; + selected_palette = 1; + } + if (comboBox1.SelectedIndex == 2) + { + label4.Text = "Mitts \\"; + selected_palette = 2; + } + if (comboBox1.SelectedIndex == 3) + { + label4.Text = ""; + selected_palette = 3; + } + refreshEverything(); + } + + private void openFileDialog5_FileOk(object sender, CancelEventArgs e) + { + tempFolders[4] = Path.GetDirectoryName(openFileDialog5.FileName); + + } + + private void button10_Click(object sender, EventArgs e) + { + ImporterForm form = new ImporterForm(); + form.ShowDialog(); + } + + private void checkBox1_CheckedChanged(object sender, EventArgs e) + { + + } + + private void button11_Click(object sender, EventArgs e) + { + openFileDialog6.ShowDialog(); + } + byte[] sprite_data = new byte[0x7078]; + private void openFileDialog6_FileOk(object sender, CancelEventArgs e) + { + //filestream open .spr file + FileStream fs = new FileStream(openFileDialog6.FileName, FileMode.Open, FileAccess.Read); + fs.Read(sprite_data,0,0x7078); + fs.Close(); + saveFileDialog6.ShowDialog(); + } + byte[] rom_patch; + private void saveFileDialog6_FileOk(object sender, CancelEventArgs e) + { + //filestream save .spr file + FileStream fs = new FileStream(saveFileDialog6.FileName, FileMode.Open, FileAccess.ReadWrite); + rom_patch = new byte[fs.Length]; + fs.Read(rom_patch, 0, (int)fs.Length); + fs.Position = 0; + + for(int i = 0;i<0x7000;i++) + { + rom_patch[0x80000 + i] = sprite_data[i]; + } + for (int i = 0; i < 0x78; i++) + { + rom_patch[0x0DD308 + i] = sprite_data[i+0x7000]; + } + + fs.Write(rom_patch, 0, (int)fs.Length); + + + fs.Close(); + } + } +} diff --git a/Form1.resx b/Form1.resx new file mode 100644 index 0000000..11c8a1b --- /dev/null +++ b/Form1.resx @@ -0,0 +1,159 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 138, 17 + + + 278, 17 + + + 418, 17 + + + 554, 17 + + + 690, 17 + + + 826, 17 + + + 17, 56 + + + 157, 56 + + + 293, 56 + + + 433, 56 + + + 569, 56 + + + 709, 56 + + \ No newline at end of file diff --git a/ImporterForm.Designer.cs b/ImporterForm.Designer.cs new file mode 100644 index 0000000..19b1337 --- /dev/null +++ b/ImporterForm.Designer.cs @@ -0,0 +1,46 @@ +namespace PaletteCreator +{ + partial class ImporterForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.SuspendLayout(); + // + // ImporterForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(513, 505); + this.Name = "ImporterForm"; + this.Text = "ImporterForm"; + this.ResumeLayout(false); + + } + + #endregion + } +} \ No newline at end of file diff --git a/ImporterForm.cs b/ImporterForm.cs new file mode 100644 index 0000000..e274cf6 --- /dev/null +++ b/ImporterForm.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace PaletteCreator +{ + public partial class ImporterForm : Form + { + public ImporterForm() + { + InitializeComponent(); + } + } +} diff --git a/ImporterForm.resx b/ImporterForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ImporterForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/PaletteCreator.csproj b/PaletteCreator.csproj new file mode 100644 index 0000000..18181fe --- /dev/null +++ b/PaletteCreator.csproj @@ -0,0 +1,102 @@ + + + + + Debug + AnyCPU + {151B95CE-E4E8-47E1-BFAC-4A35C18242D2} + WinExe + Properties + PaletteCreator + PaletteCreator + v4.5.2 + 512 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + Form + + + Form1.cs + + + Form + + + ImporterForm.cs + + + + + Form1.cs + + + ImporterForm.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + \ No newline at end of file diff --git a/Program.cs b/Program.cs new file mode 100644 index 0000000..e4a4fe4 --- /dev/null +++ b/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace PaletteCreator +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..3a29ee3 --- /dev/null +++ b/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("PaletteCreator")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("PaletteCreator")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("151b95ce-e4e8-47e1-bfac-4a35c18242d2")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs new file mode 100644 index 0000000..1f687ad --- /dev/null +++ b/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace PaletteCreator.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PaletteCreator.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/Properties/Resources.resx b/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs new file mode 100644 index 0000000..c1780f9 --- /dev/null +++ b/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace PaletteCreator.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/Properties/Settings.settings b/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/README.md b/README.md new file mode 100644 index 0000000..ac4b5ab --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# PaletteCreator