protected virtual void resetControls() { UtilsGui.setCbItemsCount(cbVideo, ConfigScript.videoOffset.recCount); UtilsGui.setCbItemsCount(cbTileset, ConfigScript.blocksOffset.recCount); UtilsGui.setCbItemsCount(cbPalette, ConfigScript.palOffset.recCount); UtilsGui.setCbIndexWithoutUpdateLevel(cbTileset, cbLevelSelect_SelectedIndexChanged, formMain.CurActiveBigBlockNo); //small blocks no? UtilsGui.setCbIndexWithoutUpdateLevel(cbVideo, VisibleOnlyChange_SelectedIndexChanged, formMain.CurActiveVideoNo); UtilsGui.setCbIndexWithoutUpdateLevel(cbPalette, VisibleOnlyChange_SelectedIndexChanged, formMain.CurActivePalleteNo); curActiveBigBlock = formMain.CurActiveBigBlockNo; //small blocks no? curActiveVideo = formMain.CurActiveVideoNo; curActivePal = formMain.CurActivePalleteNo; UtilsGui.setCbIndexWithoutUpdateLevel(cbSubpalette, cbSubpalette_SelectedIndexChanged); UtilsGui.setCbItemsCount(cbPanelNo, (ConfigScript.getBlocksCount() + BLOCKS_PER_PAGE - 1) / BLOCKS_PER_PAGE); UtilsGui.setCbIndexWithoutUpdateLevel(cbPanelNo, cbPanelNo_SelectedIndexChanged); }
protected void btFlipVertical_Click(object sender, EventArgs e) { var videoChunk = ConfigScript.getVideoChunk(curActiveVideo); int beginIndex = 16 * curActiveBlock; Utils.Swap(ref videoChunk[beginIndex + 0], ref videoChunk[beginIndex + 7]); Utils.Swap(ref videoChunk[beginIndex + 1], ref videoChunk[beginIndex + 6]); Utils.Swap(ref videoChunk[beginIndex + 2], ref videoChunk[beginIndex + 5]); Utils.Swap(ref videoChunk[beginIndex + 3], ref videoChunk[beginIndex + 4]); Utils.Swap(ref videoChunk[beginIndex + 8], ref videoChunk[beginIndex + 15]); Utils.Swap(ref videoChunk[beginIndex + 9], ref videoChunk[beginIndex + 14]); Utils.Swap(ref videoChunk[beginIndex + 10], ref videoChunk[beginIndex + 13]); Utils.Swap(ref videoChunk[beginIndex + 11], ref videoChunk[beginIndex + 12]); ConfigScript.setVideoChunk(curActiveVideo, videoChunk); cbLevelSelect_SelectedIndexChanged(sender, e); }
private void cbLevel_SelectedIndexChanged(object sender, EventArgs e) { if (cbLayoutNo.SelectedIndex == -1) { return; } bool realReload = sender == cbLayoutNo; bool reloadObjects = realReload; if (!readOnly && realReload) { if (!UtilsGui.askToSave(ref dirty, saveToFile, returnCbLevelIndex)) { return; } } curActiveLayout = cbLayoutNo.SelectedIndex; curScale = cbScale.SelectedIndex + 1; //TODO: normal scale factors; cbLayoutNo.Items.Clear(); foreach (var lr in ConfigScript.getLevelRecs()) { cbLayoutNo.Items.Add(String.Format("{0} : 0x{1:X} ({2}x{3})", lr.name, lr.layoutAddr, lr.width, lr.height)); } UtilsGui.setCbIndexWithoutUpdateLevel(cbLayoutNo, cbLevel_SelectedIndexChanged, curActiveLayout); if (sender == cbLayoutNo) { var g = getLevelRecForGameType().group; if (g != null) { UtilsGui.setCbIndexWithoutUpdateLevel(cbVideoNo, cbLevel_SelectedIndexChanged, g.videoNo); UtilsGui.setCbIndexWithoutUpdateLevel(cbBigBlockNo, cbLevel_SelectedIndexChanged, g.bigBlockNo); UtilsGui.setCbIndexWithoutUpdateLevel(cbBlockNo, cbLevel_SelectedIndexChanged, g.blockNo); UtilsGui.setCbIndexWithoutUpdateLevel(cbPaletteNo, cbLevel_SelectedIndexChanged, g.palNo); reloadLevelLayerData(); cbGroup.SelectedIndex = -1; } reloadScreens(); } reloadLevel(reloadObjects); resizeMapScreen(); mapScreen.Invalidate(); }
private void EnemyEditor_Load(object sender, EventArgs e) { KeyPreview = true; if (ConfigScript.usePicturesInstedBlocks) { //TODO: set big blocks sizes from picture bigBlocks = UtilsGDI.setBlocksForPictures(); } reloadPictures(); fillObjPanel(); UtilsGui.setCbItemsCount(cbVideoNo, ConfigScript.videoOffset.recCount); UtilsGui.setCbItemsCount(cbBigBlockNo, ConfigScript.bigBlocksOffsets[0].recCount); UtilsGui.setCbItemsCount(cbBlockNo, ConfigScript.blocksOffset.recCount); UtilsGui.setCbItemsCount(cbPaletteNo, ConfigScript.palOffset.recCount); UtilsGui.setCbItemsCount(cbScale, 2, 1); UtilsGui.setCbIndexWithoutUpdateLevel(cbVideoNo, cbLevel_SelectedIndexChanged, formMain.curActiveVideoNo); UtilsGui.setCbIndexWithoutUpdateLevel(cbBlockNo, cbLevel_SelectedIndexChanged, formMain.curActiveBlockNo); UtilsGui.setCbIndexWithoutUpdateLevel(cbBigBlockNo, cbLevel_SelectedIndexChanged, formMain.curActiveBigBlockNo); UtilsGui.setCbIndexWithoutUpdateLevel(cbPaletteNo, cbLevel_SelectedIndexChanged, formMain.curActivePalleteNo); UtilsGui.setCbIndexWithoutUpdateLevel(cbTool, cbTool_SelectedIndexChanged); UtilsGui.setCbIndexWithoutUpdateLevel(cbScale, cbLevel_SelectedIndexChanged, 1); cbLayoutNo.Items.Clear(); foreach (var lr in ConfigScript.getLevelRecs()) { cbLayoutNo.Items.Add(String.Format("{0}:0x{1:X} ({2}x{3})", lr.name, lr.layoutAddr, lr.width, lr.height)); } UtilsGui.setCbIndexWithoutUpdateLevel(cbLayoutNo, cbLevel_SelectedIndexChanged); bttSave.Enabled = ConfigScript.setObjectsFunc != null; btSort.Visible = ConfigScript.sortObjectsFunc != null; UtilsGui.setCbItemsCount(cbBigObjectNo, 256, 0, true); cbLevel_SelectedIndexChanged(cbLayoutNo, new EventArgs()); resizeMapScreen(); cbGroup.Items.Clear(); foreach (var g in ConfigScript.getGroups()) { cbGroup.Items.Add(g.name); } }
private void reloadBigBlocks() { if (!ConfigScript.usePicturesInstedBlocks) { if (ConfigScript.isUseSegaGraphics()) { bigBlocks = Globals.makeSegaBigBlocks(curVideoNo, curBigBlockNo, curPaletteNo, MapViewType.Tiles); } else if (ConfigScript.isUseGbGraphics()) { bigBlocks = Globals.makeGbBigBlocks(curVideoNo, curBigBlockNo, curPaletteNo, MapViewType.Tiles); } else { bigBlocks = ConfigScript.videoNes.makeBigBlocks(curVideoNo, curBigBlockNo, curBlockNo, curPaletteNo, MapViewType.Tiles, MapViewType.Tiles, ConfigScript.getbigBlocksHierarchyCount() - 1); } } }
private void cbGroup_SelectedIndexChanged(object sender, EventArgs e) { if (cbGroup.SelectedIndex < 0) { return; } GroupRec g = ConfigScript.getGroup(cbGroup.SelectedIndex); UtilsGui.setCbIndexWithoutUpdateLevel(cbVideoNo, cbLevel_SelectedIndexChanged, g.videoNo); UtilsGui.setCbIndexWithoutUpdateLevel(cbBigBlockNo, cbLevel_SelectedIndexChanged, g.bigBlockNo); UtilsGui.setCbIndexWithoutUpdateLevel(cbBlockNo, cbLevel_SelectedIndexChanged, g.blockNo); UtilsGui.setCbIndexWithoutUpdateLevel(cbPaletteNo, cbLevel_SelectedIndexChanged, g.palNo); cbLevel_SelectedIndexChanged(cbVideoNo, new EventArgs()); if (g.firstScreen < 0 || g.firstScreen <= cbScreenNo.Items.Count) { cbScreenNo.SelectedIndex = g.firstScreen - 1; } }
private void mapScreen_MouseClick(object sender, MouseEventArgs ea) { var ee = ea.Location; if (ee.X < 0) { ee.X += 32768 * 2; } if (ee.Y < 0) { ee.Y += 32768 * 2; } int WIDTH = ConfigScript.getScreenWidth(curActiveLevelForScreen); int HEIGHT = ConfigScript.getScreenHeight(curActiveLevelForScreen); int dx, dy; if (ConfigScript.getScreenVertical()) { dy = ee.X / (int)(layers[0].blockWidth * curScale); dx = ee.Y / (int)(layers[0].blockHeight * curScale) - 1; } else { dx = ee.X / (int)(layers[0].blockWidth * curScale) - 1; dy = ee.Y / (int)(layers[0].blockHeight * curScale); } if (ea.Button == MouseButtons.Right) { if (dx == WIDTH || dx == -1) { return; } int index = dy * WIDTH + dx; curActiveBlock = ConfigScript.getBigTileNoFromScreen(layers[0].screens[curActiveScreen], index); if (curActiveBlock != -1) { activeBlock.Image = bigBlocks[curActiveBlock]; lbActiveBlock.Text = String.Format("Label: {0:X}", curActiveBlock); } blocksScreen.Invalidate(); return; } }
private void resetControls() { curActiveLevelForScreen = 0; resetScreens(); UtilsGui.setCbItemsCount(cbVideoNo, ConfigScript.videoOffset.recCount); UtilsGui.setCbItemsCount(cbBigBlockNo, ConfigScript.bigBlocksOffsets[0].recCount); UtilsGui.setCbItemsCount(cbBlockNo, ConfigScript.blocksOffset.recCount); UtilsGui.setCbItemsCount(cbPaletteNo, ConfigScript.palOffset.recCount); UtilsGui.setCbItemsCount(cbLevelNo, ConfigScript.getLevelsCount()); UtilsGui.setCbIndexWithoutUpdateLevel(cbVideoNo, cbLevel_SelectedIndexChanged); UtilsGui.setCbIndexWithoutUpdateLevel(cbBigBlockNo, cbLevel_SelectedIndexChanged); UtilsGui.setCbIndexWithoutUpdateLevel(cbBlockNo, cbLevel_SelectedIndexChanged); UtilsGui.setCbIndexWithoutUpdateLevel(cbPaletteNo, cbLevel_SelectedIndexChanged); UtilsGui.setCbIndexWithoutUpdateLevel(cbLevelNo, cbLevelNo_SelectedIndexChanged); UtilsGui.setCbIndexWithoutUpdateLevel(cbViewType, cbLevel_SelectedIndexChanged); cbGroup.Items.Clear(); foreach (var g in ConfigScript.getGroups()) { cbGroup.Items.Add(g.name); } dirty = false; updateSaveVisibility(); showNeiScreens = true; showAxis = true; showBrush = true; useStructs = false; curActiveLayer = 0; reloadGameType(); changeLevelIndex(true); bttBigBlocks.Enabled = ConfigScript.isBigBlockEditorEnabled; bttBlocks.Enabled = ConfigScript.isBlockEditorEnabled; bttEnemies.Enabled = ConfigScript.isEnemyEditorEnabled; bttShowLayer1.Visible = ConfigScript.getLayersCount() > 1; bttShowLayer2.Visible = ConfigScript.getLayersCount() > 1; bttLayer.Visible = ConfigScript.getLayersCount() > 1; pnGroups.Visible = ConfigScript.getGroups().Length > 0; resetMapScreenSize(); }
public static void loadData(string Filename, string Dumpfile, string ConfigFilename) { try { int size = (int)new FileInfo(Filename).Length; using (FileStream f = File.OpenRead(Filename)) { romdata = new byte[size]; f.Read(romdata, 0, size); } } catch (Exception ex) { MessageBox.Show(ex.Message); } try { if (Dumpfile != "") { int size = (int)new FileInfo(Dumpfile).Length; using (FileStream f = File.OpenRead(Dumpfile)) { dumpdata = new byte[size]; f.Read(dumpdata, 0, size); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } try { ConfigScript.LoadFromFile(ConfigFilename); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public static byte[] readLinearBigBlockData(int hierLevel, int bigTileIndex, int tileSize) { //if tileSize == -1, try read it from config if (tileSize == -1) { tileSize = ConfigScript.isBlockSize4x4() ? 16 : 4; } int wordSize = ConfigScript.isUseSegaGraphics() ? 2 : 1; int size = ConfigScript.getBigBlocksCount(hierLevel) * tileSize * wordSize; byte[] bigBlockIndexes = new byte[size]; var bigBlocksAddr = ConfigScript.getBigTilesAddr(hierLevel, bigTileIndex); for (int i = 0; i < size; i++) { bigBlockIndexes[i] = Globals.romdata[bigBlocksAddr + i]; } return(bigBlockIndexes); }
private static void renderLayer(Graphics g, BlockLayer layer, RenderParams renderParams) { bool needRenderLayer = layer != null && layer.showLayer; if (!needRenderLayer) { return; } int tileSizeX = renderParams.getTileSizeX(); int tileSizeY = renderParams.getTileSizeY(); int size = renderParams.getLayerSize(); for (int i = 0; i < size; i++) { int bigBlockNo = ConfigScript.getBigTileNoFromScreen(layer.data, i); Rectangle tileRect = new Rectangle((i % renderParams.width) * tileSizeX + renderParams.leftMargin, i / renderParams.width * tileSizeY + renderParams.topMargin, tileSizeX, tileSizeY); renderParams.renderBlock(g, bigBlockNo, tileRect); } }
private void renderNeighbornLine(Graphics g, int screenNo, int line, int X) { int WIDTH = ConfigScript.getScreenWidth(curActiveLevelForScreen); int HEIGHT = ConfigScript.getScreenHeight(curActiveLevelForScreen); int TILE_SIZE_X = (int)(layers[0].blockWidth * curScale); int TILE_SIZE_Y = (int)(layers[0].blockHeight * curScale); int SIZE = WIDTH * HEIGHT; int[] indexesPrev = layers[0].screens[screenNo]; for (int i = 0; i < SIZE; i++) { if (i % WIDTH == line) { int bigBlockNo = ConfigScript.getBigTileNoFromScreen(indexesPrev, i); if (bigBlockNo < bigBlocks.Length) { g.DrawImage(bigBlocks[bigBlockNo], new Rectangle(X, i / WIDTH * TILE_SIZE_Y, TILE_SIZE_X, TILE_SIZE_Y)); } } } }
protected virtual void initControls() { UtilsGui.setCbItemsCount(cbHierarchyLevel, ConfigScript.getbigBlocksHierarchyCount()); UtilsGui.setCbItemsCount(cbVideoNo, ConfigScript.videoOffset.recCount); UtilsGui.setCbItemsCount(cbBigBlock, ConfigScript.bigBlocksOffsets[curHierarchyLevel].recCount); UtilsGui.setCbItemsCount(cbPaletteNo, ConfigScript.palOffset.recCount); cbTileset.Items.Clear(); for (int i = 0; i < ConfigScript.blocksOffset.recCount; i++) { var str = String.Format("Tileset{0}", i); cbTileset.Items.Add(str); } //generic version cbHierarchyLevel.SelectedIndex = 0; cbTileset.SelectedIndex = formMain.curActiveBlockNo; cbVideoNo.SelectedIndex = formMain.curActiveVideoNo; cbBigBlock.SelectedIndex = formMain.curActiveBigBlockNo; cbPaletteNo.SelectedIndex = formMain.curActivePalleteNo; cbViewType.SelectedIndex = Math.Min((int)formMain.curActiveViewType, cbViewType.Items.Count - 1); }
private void resizeMapScreen() { int blockWidth = formMain.Layers[0].blockWidth; int blockHeight = formMain.Layers[0].blockHeight; int scrLevelNo = getLevelRecForGameType().levelNo; int scrWidth = (int)(ConfigScript.getScreenWidth(scrLevelNo) * blockWidth * curScale); int scrHeight = (int)(ConfigScript.getScreenHeight(scrLevelNo) * blockHeight * curScale); int screensInWidth = curLevelLayerData.width; int screensInHeight = curLevelLayerData.height; if (!ConfigScript.getScreenVertical()) { mapScreen.Size = new Size(scrWidth * screensInWidth, scrHeight * screensInHeight); } else { mapScreen.Size = new Size(scrHeight * screensInWidth, scrWidth * screensInHeight); } }
public static bool setLayoutLinear(LevelLayerData curActiveLayerData, int curActiveLayout) { int layerAddr, scrollAddr, width, height; layerAddr = ConfigScript.getLayoutAddr(curActiveLayout); scrollAddr = ConfigScript.getScrollAddr(curActiveLayout); //darkwing duck specific width = curActiveLayerData.width; height = curActiveLayerData.height; for (int i = 0; i < width * height; i++) { Globals.romdata[layerAddr + i] = (byte)curActiveLayerData.layer[i]; } if (curActiveLayerData.scroll != null) { for (int i = 0; i < width * height; i++) { Globals.romdata[scrollAddr + i] = (byte)curActiveLayerData.scroll[i]; } } return(true); }
private void setBlocks(bool needRebuildBlocks) { //if using pictures if (ConfigScript.usePicturesInstedBlocks) { if (needRebuildBlocks) { //get block size from image layers[0].blockWidth = ConfigScript.getBlocksPicturesWidth(); layers[0].blockHeight = 32; layers[1].blockWidth = ConfigScript.getBlocksPicturesWidth(); layers[1].blockHeight = 32; bigBlocks = UtilsGDI.setBlocksForPictures(curButtonScale, layers[0].blockWidth, layers[0].blockHeight, curViewType); } updateBlocksImages(); return; } MapViewType smallObjectsType = curViewType == MapViewType.SmallObjNumbers ? MapViewType.ObjNumbers : curViewType == MapViewType.ObjType ? MapViewType.ObjType : MapViewType.Tiles; float smallBlockScaleFactor = curButtonScale; int bigTileIndex = curActiveBlockNo; if (needRebuildBlocks) { if (ConfigScript.isUseSegaGraphics()) { bigBlocks = makeSegaBigBlocks(); } else { bigBlocks = ConfigScript.videoNes.makeBigBlocks(curActiveVideoNo, curActiveBigBlockNo, bigTileIndex, curActivePalleteNo, smallObjectsType, curViewType, ConfigScript.getbigBlocksHierarchyCount() - 1); } changeBlocksSize(bigBlocks); } curActiveBlock = 0; updateBlocksImages(); }
private void resetScreens() { screens = ConfigScript.loadScreens(); int count = screens.Length; int oldScreenNo = cbScreenNo.SelectedIndex; cbScreenNo.Items.Clear(); for (int i = 0; i < count; i++) { cbScreenNo.Items.Add(String.Format("{0:X}", i + 1)); } if (oldScreenNo == -1) { cbScreenNo.SelectedIndex = 0; } else if (oldScreenNo < cbScreenNo.Items.Count) { cbScreenNo.SelectedIndex = oldScreenNo; } }
private void renderNeighbornLine(Graphics g, int scrNo, int line, int x) { Screen prevScreen = screens[scrNo]; int width = prevScreen.width; int height = prevScreen.height; int tileSizeX = (int)(bigBlocks[0].Width * curScale); int tileSizeY = (int)(bigBlocks[0].Height * curScale); int size = width * height; int[] indexesPrev = prevScreen.layers[0].data; for (int i = 0; i < size; i++) { if (i % width == line) { int bigBlockNo = ConfigScript.getBigTileNoFromScreen(indexesPrev, i); if ((bigBlockNo >= 0) && (bigBlockNo < bigBlocks.Length)) { g.DrawImage(bigBlocks[bigBlockNo], new Rectangle(x, i / width * tileSizeY, tileSizeX, tileSizeY)); } } } }
private void blocksScreen_MouseDown(object sender, MouseEventArgs e) { var p = blocksScreen.PointToClient(Cursor.Position); int x = p.X, y = p.Y; int tileSizeX = (int)(bigBlocks[0].Width * curScale); int tileSizeY = (int)(bigBlocks[0].Height * curScale); int tx = x / tileSizeX, ty = y / tileSizeY; int maxtX = blocksScreen.Width / tileSizeX; int index = ty * maxtX + tx; bool renderPhysics = isPhysicsLayerSelected(); int maxIndex = renderPhysics ? ConfigScript.getPhysicsBlocksCount() : bigBlocks.Length; if ((tx < 0) || (tx >= maxtX) || (index < 0) || (index >= maxIndex)) { return; } activeBlock.Image = bigBlocks[index]; curActiveBlock = index; lbActiveBlock.Text = String.Format("Label: ({0:X})", index); blocksScreen.Invalidate(); }
private void btImport_Click(object sender, EventArgs e) { var f = new SelectFile(); f.Filename = "exportedConfigScript.videoNes.bin"; f.ShowDialog(); if (!f.Result) { return; } var fn = f.Filename; var data = Utils.loadDataFromFile(fn); if (data == null) { return; } ConfigScript.setVideoChunk(curActiveVideo, data); //dirty = true; reloadVideo(); }
private void setBlocks(bool needRebuildBlocks) { //if using pictures if (ConfigScript.usePicturesInstedBlocks) { if (needRebuildBlocks) { //get block size from image int w = ConfigScript.getBlocksPicturesWidth(); int h = 32; bigBlocks = UtilsGDI.setBlocksForPictures(curScale, w, h, curActiveViewType); } } else { MapViewType smallObjectsType = curActiveViewType == MapViewType.SmallObjNumbers ? MapViewType.ObjNumbers : curActiveViewType == MapViewType.ObjType ? MapViewType.ObjType : MapViewType.Tiles; if (needRebuildBlocks) { if (ConfigScript.isUseSegaGraphics()) { bigBlocks = Globals.makeSegaBigBlocks(curActiveVideoNo, curActiveBigBlockNo, curActivePalleteNo, curActiveViewType); } else if (ConfigScript.isUseGbGraphics()) { bigBlocks = Globals.makeGbBigBlocks(curActiveVideoNo, curActiveBigBlockNo, curActivePalleteNo, curActiveViewType); } else { bigBlocks = ConfigScript.videoNes.makeBigBlocks(curActiveVideoNo, curActiveBigBlockNo, curActiveBlockNo, curActivePalleteNo, smallObjectsType, curActiveViewType, ConfigScript.getbigBlocksHierarchyCount() - 1); } } } curActiveBlock = 0; updateBlocksImages(); }
public static byte[] getPalleteLinear(int palIndex) { int pal_size = ConfigScript.isUseSegaGraphics() ? Globals.SEGA_PAL_LEN : Globals.PAL_LEN; var palette = new byte[pal_size]; int addr = ConfigScript.palOffset.beginAddr + palIndex * ConfigScript.palOffset.recSize; if (!ConfigScript.isUseSegaGraphics()) { for (int i = 0; i < pal_size; i++) { palette[i] = (byte)(Globals.romdata[addr + i] & 0x3F); } } else { for (int i = 0; i < pal_size; i++) { palette[i] = (byte)(Globals.romdata[addr + i]); } } return(palette); }
protected void mapScreen_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; int btc = ConfigScript.getBigBlocksCount(curHierarchyLevel, curBigBlockNo); int bblocksInRow = 16; var testBBlock = bigBlockIndexes[0]; int bWidth = getBlockWidth(); int bHeight = getBlockHeight(); int bbWidth = bWidth * testBBlock.width; int bbHeight = bHeight * testBBlock.height; var pen = new Pen(Brushes.Magenta); for (int i = 0; i < btc; i++) { int xb = i % bblocksInRow; int yb = i / bblocksInRow; var rr = new Rectangle(xb * bbWidth, yb * bbHeight, bbWidth, bbHeight); g.DrawImage(bigBlocksImages[i], rr); g.DrawRectangle(pen, rr); } }
public static int readBlockIndexFromMap(byte[] arrayWithData, int romAddr, int index) { int wordLen = ConfigScript.getWordLen(); bool littleEndian = ConfigScript.isLittleEndian(); int dataStride = ConfigScript.getScreenDataStride(); if (wordLen == 1) { return(ConfigScript.convertScreenTile(arrayWithData[romAddr + index * dataStride])); } else if (wordLen == 2) { if (littleEndian) { return(ConfigScript.convertScreenTile(Utils.readWordLE(arrayWithData, romAddr + index * (dataStride * wordLen)))); } else { return(ConfigScript.convertScreenTile(Utils.readWord(arrayWithData, romAddr + index * (dataStride * wordLen)))); } } return(-1); }
public static Image ScreenToImage(Image[] bigBlocks, BlockLayer[] layers, int scrNo, float CurScale, bool ShowBorder, int LeftMargin, int TopMargin, int WIDTH, int HEIGHT) { bool verticalScreen = ConfigScript.getScreenVertical(); int TILE_SIZE_X = (int)(layers[0].blockWidth * CurScale); int TILE_SIZE_Y = (int)(layers[0].blockHeight * CurScale); Image result; if (verticalScreen) { result = new Bitmap(HEIGHT * TILE_SIZE_Y, WIDTH * TILE_SIZE_X); } else { result = new Bitmap(WIDTH * TILE_SIZE_X, HEIGHT * TILE_SIZE_Y); } using (var g = Graphics.FromImage(result)) { Render(g, bigBlocks, null, layers, scrNo, CurScale, ShowBorder, false, LeftMargin, TopMargin, WIDTH, HEIGHT); } return(result); }
private void saveScreens(OffsetRec screensRec, int[][] screensData) { var arrayToSave = Globals.dumpdata != null ? Globals.dumpdata : Globals.romdata; int wordLen = ConfigScript.getWordLen(); bool littleEndian = ConfigScript.isLittleEndian(); //write back tiles int dataStride = ConfigScript.getScreenDataStride(); for (int i = 0; i < screensRec.recCount; i++) { int addr = screensRec.beginAddr + i * screensRec.recSize * (dataStride * wordLen); if (wordLen == 1) { for (int x = 0; x < screensRec.recSize; x++) { arrayToSave[addr + x * dataStride] = (byte)ConfigScript.backConvertScreenTile(screensData[i][x]); } } else if (wordLen == 2) { if (littleEndian) { for (int x = 0; x < screensRec.recSize; x++) { Utils.writeWordLE(arrayToSave, addr + x * (dataStride * wordLen), ConfigScript.backConvertScreenTile(screensData[i][x])); } } else { for (int x = 0; x < screensRec.recSize; x++) { Utils.writeWord(arrayToSave, addr + x * (dataStride * wordLen), ConfigScript.backConvertScreenTile(screensData[i][x])); } } } } }
private void mapScreen_MouseClick(object sender, MouseEventArgs e) { if (curTileStruct == null) { return; } int WIDTH = curTileStruct.Width; int HEIGHT = curTileStruct.Height; int dx, dy; if (ConfigScript.getScreenVertical()) { dy = e.X / (int)(blockWidth * curScale); dx = e.Y / (int)(blockHeight * curScale); } else { dx = e.X / (int)(blockWidth * curScale); dy = e.Y / (int)(blockHeight * curScale); } if (dx < 0 || dx >= curTileStruct.Width || dy < 0 || dy >= curTileStruct.Height) { return; } if (e.Button == MouseButtons.Left) { curTileStruct[dx, dy] = curActiveBlock; } else { curActiveBlock = curTileStruct[dx, dy]; } mapScreen.Invalidate(); }
private void mapScreen_MouseClick(object sender, MouseEventArgs ea) { var ee = ea.Location; if (ee.X < 0) { ee.X += 32768 * 2; } if (ee.Y < 0) { ee.Y += 32768 * 2; } var screen = getActiveScreen(); int width = screen.width; int dx = ee.X / (int)(bigBlocks[0].Width * curScale) - 1; int dy = ee.Y / (int)(bigBlocks[0].Height * curScale); if (ea.Button == MouseButtons.Right) { if (dx == width || dx == -1) { return; } int index = dy * width + dx; var layer = getActiveLayer(screens[screenNo]); curActiveBlock = ConfigScript.getBigTileNoFromScreen(layer.data, index); if (curActiveBlock != -1) { activeBlock.Image = bigBlocks[curActiveBlock]; lbActiveBlock.Text = String.Format("Label: {0:X}", curActiveBlock); } blocksScreen.Invalidate(); } }
public static void loadEnemyPictures(ref ImageList objectSprites, ref Image[] objectSpritesBig) { const int OBJECTS_COUNT = 256; //limit for now var objSpritesDir = ConfigScript.getObjTypesPicturesDir(); var objSpritesDirGeneric = "obj_sprites"; var templ = objSpritesDir + "/object{0}.png"; var templBig = objSpritesDir + "/object{0}b.png"; var templGenericBig = objSpritesDirGeneric + "/object{0}b.png"; objectSprites.Images.Clear(); objectSprites.Images.AddStrip(Image.FromFile(objSpritesDirGeneric + "/objSprites.png")); objectSpritesBig = new Image[256]; for (int i = 0; i < OBJECTS_COUNT; i++) { var fname = String.Format(templ, i); if (File.Exists(fname)) { objectSprites.Images[i] = Image.FromFile(fname); } // var fnameBig = String.Format(templBig, i); var fnameGenericBig = String.Format(templGenericBig, i); if (File.Exists(fnameBig)) { objectSpritesBig[i] = Image.FromFile(fnameBig); } else if (File.Exists(fnameGenericBig)) { objectSpritesBig[i] = Image.FromFile(fnameGenericBig); } else { objectSpritesBig[i] = objectSprites.Images[i]; } } }
private void mapScreen_Paint(object sender, PaintEventArgs e) { var g = e.Graphics; paintBack(g); int blockWidth = formMain.Layers[0].blockWidth; int blockHeight = formMain.Layers[0].blockHeight; int scrLevelNo = getLevelRecForGameType().levelNo; int scrWidth = (int)(ConfigScript.getScreenWidth(scrLevelNo) * blockWidth * curScale); int scrHeight = (int)(ConfigScript.getScreenHeight(scrLevelNo) * blockHeight * curScale); for (int objListIndex = 0; objListIndex < objectLists.Count; objListIndex++) { var activeObjectList = objectLists[objListIndex]; var selectedRows = dgvObjects.SelectedRows; for (int i = 0; i < activeObjectList.objects.Count; i++) { var curObject = activeObjectList.objects[i]; int leftMargin = (ConfigScript.getScreenVertical() ? scrHeight : scrWidth) * curObject.sx; int topMargin = (ConfigScript.getScreenVertical() ? scrWidth : scrHeight) * curObject.sy; bool inactive = objListIndex != curActiveObjectListIndex; bool selected = !inactive && selectedRows.Cast <DataGridViewRow>().Any(r => (r.Index == i)); if (!useBigPictures) { ConfigScript.drawObject(g, curObject, curActiveObjectListIndex, selected, curScale, objectSprites, inactive, leftMargin, topMargin); } else { ConfigScript.drawObjectBig(g, curObject, curActiveObjectListIndex, selected, curScale, objectSpritesBig, inactive, leftMargin, topMargin); } } } }