public void Execute(FormScript formScript) { formScript.writeLog(); formScript.writeLog("Script to export 2x2 blocks and blocks attributes to five separate arrays (SoA - Structure of Arrays)"); var formMain = formScript.getFormMain(); formScript.writeLog(); int curActiveBlockset = formMain.curActiveBigBlockNo; var blocks = ConfigScript.getBlocks(curActiveBlockset); int blocksCount = blocks.Length; formScript.writeLog(String.Format("Current selected block set: {0}. Blocks count: {1}", curActiveBlockset, blocksCount)); var data = new byte[blocksCount * 5]; //cad editor function to write 2x2 blocks (optional with palBytes and types) to data array in SoA form Utils.writeBlocksToAlignedArrays(blocks, data, 0, blocksCount, withPal: true, writeType: false); for (int part = 0; part < 5; part++) { //prepare data part var dataPart = new byte[blocksCount]; Array.Copy(data, blocksCount * part, dataPart, 0, blocksCount); //and write it to file var fname = ConfigScript.ConfigDirectory + String.Format("blocks{0}_part{1}.bin", curActiveBlockset, part); using (FileStream f = File.OpenWrite(fname)) { f.Write(dataPart, 0, dataPart.Length); } formScript.writeLog(String.Format(" Part {0} saved to file {1}", part, fname)); } }
public void Execute(FormScript formScript) { formScript.writeLog(); formScript.writeLog("Script for export current screen to png image"); var formMain = formScript.getFormMain(); formScript.writeLog(); int currentScreenNo = formMain.screenNo; formScript.writeLog(String.Format("Current active screen: {0}", currentScreenNo)); var activeScreen = formMain.screens[currentScreenNo]; int w = activeScreen.width; int h = activeScreen.height; var im = MapEditor.screenToImage(formMain.screens, currentScreenNo, new MapEditor.RenderParams { bigBlocks = formMain.bigBlocks, curScale = formMain.curScale, width = w, height = h, }); var fname = ConfigScript.ConfigDirectory + String.Format("screen{0}.png", currentScreenNo); im.Save(fname); formScript.writeLog(String.Format("Screen exported to file: {0}", fname)); }
public void Execute(FormScript formScript) { formScript.writeLog(); formScript.writeLog("Script for export all CHRs to png files"); var romdata = Globals.romdata; //information about video int chrDumpsCount = ConfigScript.videoOffset.recCount; formScript.writeLog(); formScript.writeLog(String.Format("Video chunks count: {0}", chrDumpsCount)); formScript.writeLog("--------------------------------------------------------------------"); var formMain = formScript.getFormMain(); int palNo = formMain.curActivePalleteNo; var pal = ConfigScript.getPal(palNo); for (int i = 0; i < chrDumpsCount; i++) { var chr = ConfigScript.getVideoChunk(i); var nesVideo = ConfigScript.videoNes; var png = nesVideo.makeImageRectangle(chr, pal, 0); var fname = ConfigScript.ConfigDirectory + String.Format("chr_{0:000}.png", i); png.Save(fname); formScript.writeLog(String.Format("Video chunk {0} saved to file: {1}", i, fname)); } formScript.writeLog("--------------------------------------------------------------------"); formScript.writeLog(); }
public void Execute(FormScript formScript) { formScript.writeLog(); formScript.writeLog("Script for find unused blocks at all screens"); var formMain = formScript.getFormMain(); //int scrNo = formMain.ScreenNo; //formScript.writeLog(String.Format("Current active screen: 0x{0:X}", scrNo)); int totalBlocksCount = formMain.bigBlocks.Length; formScript.writeLog(String.Format("Total big blocks count: {0}", totalBlocksCount)); int[] usedBlocks = new int[totalBlocksCount]; var screens = formMain.screens; //count all used blocks for (int scrNo = 0; scrNo < screens.Length; scrNo++) { var activeScreen = screens[scrNo]; for (int layerNo = 0; layerNo < activeScreen.layers.Length; layerNo++) { var data = activeScreen.layers[layerNo].data; for (int i = 0; i < data.Length; i++) { int blockNo = data[i]; usedBlocks[blockNo]++; } } } //print info about unused blocks var unusedBlocks = usedBlocks.Select((c, index) => new { Count = c, Index = index }).Where(c => c.Count == 0).Select(c => c.Index).ToArray(); formScript.writeLog("Unused blocks:", newLine: false); for (int i = 0; i < unusedBlocks.Length; i++) { formScript.writeLog(String.Format(" 0x{0:X}", unusedBlocks[i]), newLine: false); } int unusedBlocksCount = unusedBlocks.Length; if (unusedBlocksCount == 0) { formScript.writeLog(" not found", newLine: false); } formScript.writeLog(); formScript.writeLog(String.Format("Total unused blocks: {0}", unusedBlocksCount)); if (unusedBlocksCount > 0) { var unusedPictures = formMain.bigBlocks.Where((im, index) => unusedBlocks.Contains(index)).ToArray(); var glueImage = UtilsGDI.GlueImages(unusedPictures, unusedPictures.Length, 1); var fname = ConfigScript.ConfigDirectory + String.Format("unusedBlocks.png"); glueImage.Save(fname); formScript.writeLog(String.Format("Unused blocks image saved to file: {0}", fname)); } }
public void Execute(FormScript formScript) { formScript.writeLog(); formScript.writeLog("Script for export current screen to binary array (one byte per index)"); var formMain = formScript.getFormMain(); formScript.writeLog(); int currentScreenNo = formMain.screenNo; formScript.writeLog(String.Format("Current active screen: {0}", currentScreenNo)); var activeScreen = formMain.screens[currentScreenNo].layers[0].data; var data = activeScreen.Select(x => (byte)x).ToArray(); var fname = ConfigScript.ConfigDirectory + String.Format("screen{0}.bin", currentScreenNo); using (FileStream f = File.OpenWrite(fname)) { f.Write(data, 0, data.Length); } formScript.writeLog(String.Format("Screen exported to file: {0}", fname)); }