Exemplo n.º 1
0
        protected void mapScreen_MouseMove(object sender, MouseEventArgs e)
        {
            int addIndexesText = curPart * 256;

            int btc          = Math.Min(ConfigScript.getBigBlocksCount(curHierarchyLevel), 256);
            int bblocksInRow = 16;
            int bblocksInCol = (btc / bblocksInRow) + 1;

            var testBBlock = bigBlockIndexes[0];
            int bWidth     = getBlockWidth();
            int bHeight    = getBlockHeight();
            int bbWidth    = bWidth * testBBlock.width;
            int bbHeight   = bHeight * testBBlock.height;

            int bx  = e.X / bbWidth;
            int by  = e.Y / bbHeight;
            int dx  = (e.X % bbWidth) / bWidth;
            int dy  = (e.Y % bbHeight) / bHeight;
            int ind = ((by * bblocksInRow + bx) * testBBlock.getSize() + (dy * testBBlock.width + dx)) / testBBlock.getSize();

            if (ind > 255)
            {
                lbBigBlockNo.Text = "()";
            }
            else
            {
                int actualIndex = addIndexesText + ind;
                lbBigBlockNo.Text = String.Format("({0:X})", actualIndex);
            }
        }
Exemplo n.º 2
0
        protected virtual void setSmallBlocks()
        {
            smallBlocksImages = new Image[4][];

            if (curHierarchyLevel == 0)
            {
                if (hasSmallBlocksPals())
                {
                    smallBlocksImages[0] = ConfigScript.videoNes.makeObjects(curVideo, curTileset, curPallete, curViewType);
                }
                else
                {
                    fillSmallBlockImageLists();
                }
            }
            else
            {
                smallBlocksImages[0] = ConfigScript.videoNes.makeBigBlocks(curVideo, curTileset, ConfigScript.getBigBlocksRecursive(curHierarchyLevel - 1, curSmallBlockNo), curPallete, curViewType, MapViewType.Tiles, curHierarchyLevel - 1);
            }
            reloadBlocksPanel();

            //prerender big blocks
            bigBlocksImages = ConfigScript.videoNes.makeBigBlocks(curVideo, curTileset, bigBlockIndexes, curPallete, curViewType, MapViewType.Tiles, curHierarchyLevel);
            //
            int btc          = Math.Min(ConfigScript.getBigBlocksCount(curHierarchyLevel), 256);
            int bblocksInRow = 16;
            int bblocksInCol = (btc / bblocksInRow) + 1;

            //
            mapScreen.Size = new Size(bigBlocksImages[0].Width * bblocksInRow, bigBlocksImages[0].Height * bblocksInCol);
        }
Exemplo n.º 3
0
        protected void mapScreen_Paint(object sender, PaintEventArgs e)
        {
            int      addIndexes   = curPart * 256;
            Graphics g            = e.Graphics;
            int      btc          = Math.Min(ConfigScript.getBigBlocksCount(curHierarchyLevel), 256);
            int      bblocksInRow = 16;
            int      bblocksInCol = (btc / bblocksInRow) + 1;

            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[addIndexes + i], rr);
                g.DrawRectangle(pen, rr);
            }
        }
Exemplo n.º 4
0
        //copy-paste
        private Image[] makeSegaBigBlocks()
        {
            byte[] mapping    = ConfigScript.getSegaMapping(curBigBlockNo);
            byte[] videoTiles = ConfigScript.getVideoChunk(curVideoNo);
            byte[] pal        = ConfigScript.getPal(curPaletteNo);
            int    count      = ConfigScript.getBigBlocksCount(ConfigScript.getbigBlocksHierarchyCount() - 1);

            return(ConfigScript.videoSega.makeBigBlocks(mapping, videoTiles, pal, count, MapViewType.Tiles));
        }
Exemplo n.º 5
0
        public static Image[] makeSegaBigBlocks(int curActiveVideoNo, int curActiveBigBlockNo, int curActivePalleteNo, MapViewType curViewType)
        {
            byte[] mapping    = ConfigScript.getSegaMapping(curActiveBigBlockNo);
            byte[] videoTiles = ConfigScript.getVideoChunk(curActiveVideoNo);
            byte[] pal        = ConfigScript.getPal(curActivePalleteNo);
            int    count      = ConfigScript.getBigBlocksCount(ConfigScript.getbigBlocksHierarchyCount() - 1, curActiveBigBlockNo);

            return(ConfigScript.videoSega.makeBigBlocks(mapping, videoTiles, pal, count, curViewType));
        }
Exemplo n.º 6
0
        public static Image[] makeGbBigBlocks(int curActiveVideoNo, int curActiveBigBlockNo, int curActivePalleteNo, MapViewType curViewType)
        {
            byte[]   videoTiles = ConfigScript.getVideoChunk(curActiveVideoNo);
            ObjRec[] blocks     = ConfigScript.getBlocksFunc(curActiveBigBlockNo);
            var      blocksData = new byte[blocks.Length * 4]; //hardcode small blocks sizes

            Utils.writeBlocksLinear(blocks, blocksData, 0, 256, false, false);
            byte[] pal   = ConfigScript.getPal(curActivePalleteNo);
            int    count = ConfigScript.getBigBlocksCount(ConfigScript.getbigBlocksHierarchyCount() - 1, curActiveBigBlockNo);

            return(ConfigScript.videoGb.makeBigBlocks(videoTiles, blocksData, pal, count, curViewType));
        }
Exemplo n.º 7
0
        private void cbLevelPair_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (
                cbTileset.SelectedIndex == -1 ||
                cbVideoNo.SelectedIndex == -1 ||
                cbPaletteNo.SelectedIndex == -1 ||
                cbPart.SelectedIndex == -1 ||
                cbViewType.SelectedIndex == -1 ||
                cbSmallBlock.SelectedIndex == -1 ||
                cbHierarchyLevel.SelectedIndex == -1
                )
            {
                return;
            }
            if (!readOnly && dirty && (sender == cbTileset || sender == cbHierarchyLevel))
            {
                DialogResult dr = MessageBox.Show("Tiles was changed. Do you want to save current tileset?", "Save", MessageBoxButtons.YesNoCancel);
                if (dr == DialogResult.Cancel)
                {
                    returnCbLevelIndexes();
                    return;
                }
                else if (dr == DialogResult.Yes)
                {
                    if (!saveToFile())
                    {
                        returnCbLevelIndexes();
                        return;
                    }
                }
                else
                {
                    dirty = false;
                    updateSaveVisibility();
                }
            }

            //generic version
            curHierarchyLevel = cbHierarchyLevel.SelectedIndex;
            curTileset        = cbTileset.SelectedIndex;
            curSmallBlockNo   = cbSmallBlock.SelectedIndex;
            curViewType       = (MapViewType)cbViewType.SelectedIndex;

            curVideo   = cbVideoNo.SelectedIndex;
            curPallete = cbPaletteNo.SelectedIndex;
            curPart    = cbPart.SelectedIndex;
            UtilsGui.setCbItemsCount(cbPart, Math.Max(ConfigScript.getBigBlocksCount(curHierarchyLevel) / 256, 1));
            UtilsGui.setCbIndexWithoutUpdateLevel(cbPart, cbLevelPair_SelectedIndexChanged, curPart);
            reloadLevel();
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
        protected virtual void initControls()
        {
            UtilsGui.setCbItemsCount(cbHierarchyLevel, ConfigScript.getbigBlocksHierarchyCount());
            UtilsGui.setCbItemsCount(cbVideoNo, ConfigScript.videoOffset.recCount);
            UtilsGui.setCbItemsCount(cbSmallBlock, ConfigScript.blocksOffset.recCount);
            UtilsGui.setCbItemsCount(cbPaletteNo, ConfigScript.palOffset.recCount);
            UtilsGui.setCbItemsCount(cbPart, Math.Max(ConfigScript.getBigBlocksCount(curHierarchyLevel) / 256, 1));
            cbTileset.Items.Clear();
            for (int i = 0; i < ConfigScript.bigBlocksOffsets[curTileset].recCount; i++)
            {
                var str = String.Format("Tileset{0}", i);
                cbTileset.Items.Add(str);
            }

            //generic version
            cbHierarchyLevel.SelectedIndex = 0;
            cbTileset.SelectedIndex        = formMain.CurActiveBigBlockNo;
            cbVideoNo.SelectedIndex        = formMain.CurActiveVideoNo;
            cbSmallBlock.SelectedIndex     = formMain.CurActiveBlockNo;
            cbPaletteNo.SelectedIndex      = formMain.CurActivePalleteNo;
            cbPart.SelectedIndex           = 0;
            cbViewType.SelectedIndex       = Math.Min((int)formMain.CurActiveViewType, cbViewType.Items.Count - 1);
        }
Exemplo n.º 10
0
 private int getBlocksCount()
 {
     return(editMapMode ? 1 : ConfigScript.getBigBlocksCount(0, 0));
 }
Exemplo n.º 11
0
        protected void mapScreen_MouseClick(object sender, MouseEventArgs e)
        {
            int addIndexes = curPart * 256;

            dirty = true; updateSaveVisibility();

            int btc          = Math.Min(ConfigScript.getBigBlocksCount(curHierarchyLevel), 256);
            int bblocksInRow = 16;
            int bblocksInCol = (btc / bblocksInRow) + 1;

            var testBBlock = bigBlockIndexes[0];
            int bWidth     = getBlockWidth();
            int bHeight    = getBlockHeight();
            int bbWidth    = bWidth * testBBlock.width;
            int bbHeight   = bHeight * testBBlock.height;

            int bx            = e.X / bbWidth;
            int by            = e.Y / bbHeight;
            int dx            = (e.X % bbWidth) / bWidth;
            int dy            = (e.Y % bbHeight) / bHeight;
            int bigBlockIndex = by * bblocksInRow + bx;
            int insideIndex   = dy * testBBlock.width + dx;

            //prevent out in bounds
            if (bigBlockIndex >= btc)
            {
                return;
            }
            int actualIndex = addIndexes + bigBlockIndex;

            if (e.Button == MouseButtons.Left)
            {
                if (actualIndex < bigBlockIndexes.Length)
                {
                    bigBlockIndexes[actualIndex].indexes[insideIndex] = curActiveBlock;
                }
            }
            else
            {
                //first action - change pal byte if it applicable
                if (!hasSmallBlocksPals())
                {
                    if (actualIndex < bigBlockIndexes.Length)
                    {
                        var bbPal = bigBlockIndexes[actualIndex] as BigBlockWithPal;
                        if (bbPal == null)
                        {
                            return;
                        }
                        //
                        int palByte = bbPal.palBytes[insideIndex];
                        if (++palByte > 3)
                        {
                            palByte = 0;
                        }
                        bbPal.palBytes[insideIndex] = palByte;
                        //
                    }
                }
                //second action - change cur active block to selected
                if (actualIndex < bigBlockIndexes.Length)
                {
                    curActiveBlock = bigBlockIndexes[actualIndex].indexes[insideIndex];
                }
                pbActive.Image = smallBlocksImages[0][curActiveBlock];
                lbActive.Text  = String.Format("({0:X})", curActiveBlock);
                blocksScreen.Invalidate();
            }

            //fix current big blocks image
            bigBlocksImages[actualIndex] = bigBlockIndexes[actualIndex].makeBigBlock(smallBlocksImages);
            mapScreen.Invalidate();
        }