private void WriteROMIcon() { const int ImageSize = 512; const int PaletteSize = 32; // Virtual banner file used in NSMBe simplifies this a lot var banner_f = NSMBeROM.getLevelFile("banner"); var image_f = new InlineFile(banner_f, PaletteSize, ImageSize, banner_f.name); var palette_f = new InlineFile(banner_f, ImageSize + PaletteSize, PaletteSize, banner_f.name); var image = new Image2D(image_f, 32, true, false); var palette = new FilePalette(palette_f); image.replaceImgAndPal(Icon, palette); Array.Copy(image.getData(), ROM.Banner.Banner.Image, ImageSize); Array.Copy(palette.getData(), ROM.Banner.Banner.Pltt, PaletteSize); }
private void DoWithNSMBeROM(string path, System.Action callback) { NSMBeROM.load(new NSMBeROMFs(path)); callback(); NSMBeROM.close(); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); string langDir = System.IO.Path.Combine(Application.StartupPath, "Languages"); string langFileName = System.IO.Path.Combine(langDir, Properties.Settings.Default.LanguageFile + ".ini"); if (System.IO.File.Exists(langFileName)) { System.IO.StreamReader rdr = new StreamReader(langFileName); LanguageManager.Load(rdr.ReadToEnd().Split('\n')); rdr.Close(); } else { MessageBox.Show("File " + langFileName + " could not be found, so the language has defaulted to English."); LanguageManager.Load(Properties.Resources.English.Split('\n')); } //This makes the editor behave BAD when no internet. //This actually catches the error now, but I'm leaving it disabled because the Sprite DB outputs a corrupt file //if (Properties.Settings.Default.AutoUpdateSD) // SpriteData.update(); string path = ""; string[] args = Environment.GetCommandLineArgs(); string[] backups = null; if (Properties.Settings.Default.BackupFiles != "" && MessageBox.Show("NSMBe did not shut down correctly and has recovered some of your levels.\nWould you like to open those now? If not, they can be opened later from the /Backup folder", "Open backups?", MessageBoxButtons.YesNo) == DialogResult.Yes) { backups = Properties.Settings.Default.BackupFiles.Split(';'); path = backups[0]; } else if (args.Length > 1) { path = args[1]; } else { OpenFileDialog openROMDialog = new OpenFileDialog(); openROMDialog.Filter = LanguageManager.Get("LevelChooser", "ROMFilter"); if (openROMDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { path = openROMDialog.FileName; } } if (path != "") { // try { ROM.load(path); } /* catch (Exception ex) * { * MessageBox.Show("Could not open ROM file for writing. Is it open with other program?\n\n"+ex.Message); * return; * } */ if (args.Length > 2 && args[2] == "asmpatch") { PatchMaker pm = new PatchMaker(ROM.romfile.Directory); pm.restore(); pm.generatePatch(); } else if (args.Length > 2 && args[2] == "getcodeaddr") { PatchMaker pm = new PatchMaker(ROM.romfile.Directory); pm.restore(); Console.Out.WriteLine(String.Format("{0:X8}", pm.getCodeAddr())); } else { if (backups != null) { for (int l = 1; l < backups.Length; l++) { ROM.fileBackups.Add(backups[l]); } } SpriteData.Load(); if (Properties.Settings.Default.mdi) { Application.Run(new MdiParentForm()); } else { Application.Run(new LevelChooser()); } } } }
public static void copyData(byte[] data) { Clipboard.SetText(clipboardHeader + Convert.ToBase64String(ROM.LZ77_Compress(data)) + clipboardFooter); }
public void LoadTilesets(ushort TilesetID, int JyotyuPalOverride) { Tilesets = new NSMBTileset[3]; Console.WriteLine("JyotyuPalOverride = {0}, JyotyuPal offset = {1}...", JyotyuPalOverride, ROM.Overlay0[ROM.GetOffset(ROM.Data.Table_Jyotyu_NCL) + JyotyuPalOverride]); byte JyotyuPalID = ROM.Overlay0[ROM.GetOffset(ROM.Data.Table_Jyotyu_NCL) + JyotyuPalOverride]; File JyotyuPalFile = null; if (JyotyuPalID == 1) { JyotyuPalFile = ROM.FS.getFileByName("d_2d_A_J_jyotyu_B_ncl.bin"); } else if (JyotyuPalID == 2) { JyotyuPalFile = ROM.FS.getFileByName("d_2d_A_J_jyotyu_R_ncl.bin"); } else if (JyotyuPalID == 3) { JyotyuPalFile = ROM.FS.getFileByName("d_2d_A_J_jyotyu_W_ncl.bin"); } else { JyotyuPalFile = ROM.FS.getFileByName("d_2d_A_J_jyotyu_ncl.bin"); } Tilesets[0] = new NSMBTileset( ROM.FS.getFileByName("d_2d_A_J_jyotyu_ncg.bin"), JyotyuPalFile, ROM.FS.getFileByName("d_2d_PA_A_J_jyotyu.bin"), ROM.FS.getFileByName("A_J_jyotyu.bin"), ROM.FS.getFileByName("A_J_jyotyu_hd.bin"), null, true, 0); LoadTileset1(TilesetID); Tilesets[2] = new NSMBTileset( ROM.FS.getFileByName("d_2d_I_S_tikei_nohara_ncg.bin"), ROM.FS.getFileByName("d_2d_I_S_tikei_nohara_ncl.bin"), ROM.FS.getFileByName("d_2d_PA_I_S_nohara.bin"), ROM.FS.getFileByName("I_S_nohara.bin"), ROM.FS.getFileByName("I_S_nohara_hd.bin"), ROM.FS.getFileByName("NoHaRaSubUnitChangeData.bin"), false, 2); // Patch in a bunch of overrides to the normal tileset // Now works directly on the map16 data Tilesets[0].UseOverrides = true; Tilesets[0].Overrides[36] = 135; Tilesets[0].Overrides[112] = 26; Tilesets[0].Overrides[113] = 27; Tilesets[0].Overrides[114] = 53; Tilesets[0].Overrides[115] = 55; Tilesets[0].Overrides[116] = 28; Tilesets[0].Overrides[117] = 57; Tilesets[0].Overrides[118] = 0; Tilesets[0].Overrides[119] = 1; Tilesets[0].Overrides[120] = 4; Tilesets[0].Overrides[121] = 5; Tilesets[0].Overrides[122] = 30; Tilesets[0].Overrides[123] = 31; Tilesets[0].Overrides[124] = 8; Tilesets[0].Overrides[125] = 9; Tilesets[0].Overrides[126] = 20; Tilesets[0].Overrides[127] = 21; Tilesets[0].Overrides[128] = 24; Tilesets[0].Overrides[129] = 25; Tilesets[0].Overrides[132] = 29; Tilesets[0].Overrides[130] = 54; Tilesets[0].Overrides[131] = 56; Tilesets[0].Overrides[133] = 58; Tilesets[0].Overrides[134] = 2; Tilesets[0].Overrides[135] = 3; Tilesets[0].Overrides[136] = 6; Tilesets[0].Overrides[137] = 7; Tilesets[0].Overrides[138] = 12; Tilesets[0].Overrides[139] = 13; Tilesets[0].Overrides[140] = 10; Tilesets[0].Overrides[141] = 11; Tilesets[0].Overrides[142] = 22; Tilesets[0].Overrides[143] = 23; Tilesets[0].Overrides[145] = 32; Tilesets[0].Overrides[146] = 19; Tilesets[0].Overrides[147] = 17; Tilesets[0].Overrides[148] = 18; Tilesets[0].Overrides[149] = 14; Tilesets[0].Overrides[150] = 22; Tilesets[0].Overrides[151] = 23; Tilesets[0].Overrides[152] = 71; Tilesets[0].Overrides[153] = 72; Tilesets[0].Overrides[154] = 15; Tilesets[0].Overrides[155] = 16; Tilesets[0].Overrides[156] = 20; Tilesets[0].Overrides[157] = 21; Tilesets[0].Overrides[158] = 28; Tilesets[0].Overrides[159] = 29; Tilesets[0].Overrides[160] = 71; Tilesets[0].Overrides[161] = 72; Tilesets[0].Overrides[171] = 53; Tilesets[0].Overrides[172] = 57; Tilesets[0].Overrides[173] = 55; Tilesets[0].Overrides[174] = 26; Tilesets[0].Overrides[175] = 27; Tilesets[0].Overrides[187] = 54; Tilesets[0].Overrides[188] = 58; Tilesets[0].Overrides[189] = 56; Tilesets[0].Overrides[190] = 24; Tilesets[0].Overrides[191] = 25; Tilesets[0].Overrides[192] = 59; Tilesets[0].Overrides[193] = 63; Tilesets[0].Overrides[194] = 61; Tilesets[0].Overrides[195] = 65; Tilesets[0].Overrides[196] = 69; Tilesets[0].Overrides[197] = 67; Tilesets[0].Overrides[198] = 33; Tilesets[0].Overrides[199] = 34; Tilesets[0].Overrides[200] = 41; Tilesets[0].Overrides[201] = 42; Tilesets[0].Overrides[202] = 37; Tilesets[0].Overrides[203] = 38; Tilesets[0].Overrides[204] = 47; Tilesets[0].Overrides[205] = 48; Tilesets[0].Overrides[206] = 51; Tilesets[0].Overrides[207] = 52; Tilesets[0].Overrides[208] = 60; Tilesets[0].Overrides[209] = 64; Tilesets[0].Overrides[210] = 62; Tilesets[0].Overrides[211] = 66; Tilesets[0].Overrides[212] = 70; Tilesets[0].Overrides[213] = 68; Tilesets[0].Overrides[214] = 35; Tilesets[0].Overrides[215] = 36; Tilesets[0].Overrides[216] = 43; Tilesets[0].Overrides[217] = 44; Tilesets[0].Overrides[218] = 39; Tilesets[0].Overrides[219] = 40; Tilesets[0].Overrides[220] = 49; Tilesets[0].Overrides[221] = 50; Tilesets[0].Overrides[222] = 45; Tilesets[0].Overrides[223] = 46; Tilesets[0].Overrides[228] = 41; Tilesets[0].Overrides[229] = 42; Tilesets[0].Overrides[230] = 45; Tilesets[0].Overrides[231] = 65; Tilesets[0].Overrides[232] = 69; Tilesets[0].Overrides[233] = 67; Tilesets[0].Overrides[234] = 47; Tilesets[0].Overrides[235] = 48; Tilesets[0].Overrides[236] = 52; Tilesets[0].Overrides[237] = 59; Tilesets[0].Overrides[238] = 63; Tilesets[0].Overrides[239] = 61; Tilesets[0].Overrides[244] = 43; Tilesets[0].Overrides[245] = 44; Tilesets[0].Overrides[246] = 46; Tilesets[0].Overrides[247] = 66; Tilesets[0].Overrides[248] = 70; Tilesets[0].Overrides[249] = 68; Tilesets[0].Overrides[250] = 49; Tilesets[0].Overrides[251] = 50; Tilesets[0].Overrides[252] = 51; Tilesets[0].Overrides[253] = 60; Tilesets[0].Overrides[254] = 64; Tilesets[0].Overrides[255] = 62; // Tilesets[0].repaintAllMap16(); RepatchBlocks(Properties.Settings.Default.SmallBlockOverlays); // Enable notes for the normal tileset Tilesets[0].UseNotes = true; if (ROM.UserInfo.descriptions.ContainsKey(65535)) { Tilesets[0].ObjNotes = ROM.UserInfo.descriptions[65535].ToArray(); } else { Tilesets[0].ObjNotes = GetDescriptions(LanguageManager.GetList("ObjNotes")); } if (ROM.UserInfo.descriptions.ContainsKey(TilesetID)) { Tilesets[1].ObjNotes = ROM.UserInfo.descriptions[TilesetID].ToArray();; Tilesets[1].UseNotes = true; } if (ROM.UserInfo.descriptions.ContainsKey(65534)) { Tilesets[2].ObjNotes = ROM.UserInfo.descriptions[65534].ToArray(); Tilesets[2].UseNotes = true; } }
private void tilesetPreviewButton_Click(object sender, EventArgs e) { ushort GFXFileID = ROM.GetFileIDFromTable(tilesetComboBox.SelectedIndex, ROM.Data.Table_TS_NCG); ushort PalFileID = ROM.GetFileIDFromTable(tilesetComboBox.SelectedIndex, ROM.Data.Table_TS_NCL); }