コード例 #1
0
        public Bitmap[] makeObjects(int videoPageId, int tilesId, int palId, MapViewType drawType, int constantSubpal = -1)
        {
            byte[]   videoChunk = ConfigScript.getVideoChunk(videoPageId);
            ObjRec[] objects    = ConfigScript.getBlocks(tilesId);

            byte[] palette   = ConfigScript.getPal(palId);
            var    range256  = Enumerable.Range(0, 256);
            var    objStrip1 = range256.Select(i => makeImage(i, videoChunk, palette, 0)).ToArray();
            var    objStrip2 = range256.Select(i => makeImage(i, videoChunk, palette, 1)).ToArray();
            var    objStrip3 = range256.Select(i => makeImage(i, videoChunk, palette, 2)).ToArray();
            var    objStrip4 = range256.Select(i => makeImage(i, videoChunk, palette, 3)).ToArray();
            var    objStrips = new[] { objStrip1, objStrip2, objStrip3, objStrip4 };

            var bitmaps = makeObjects(objects, objStrips, drawType, constantSubpal);

            return(bitmaps);
        }
コード例 #2
0
ファイル: Globals.cs プロジェクト: jonthomasson/NESGameOMatic
        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);
            }
        }
コード例 #3
0
ファイル: Utils.cs プロジェクト: jonthomasson/NESGameOMatic
        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);
        }
コード例 #4
0
ファイル: Utils.cs プロジェクト: jonthomasson/NESGameOMatic
        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);
        }
コード例 #5
0
        //make capcom screen image
        public Bitmap makeScreen(int scrNo, int levelNo, int videoNo, int bigBlockNo, int blockNo, int palleteNo, bool withBorders = true)
        {
            if (scrNo < 0)
            {
                return(VideoHelper.emptyScreen((int)(ConfigScript.getScreenWidth(levelNo) * 32), (int)(ConfigScript.getScreenHeight(levelNo) * 32)));
            }
            var bigBlocks = makeBigBlocks(videoNo, bigBlockNo, blockNo, palleteNo, MapViewType.Tiles, MapViewType.Tiles);

            //var bigBlocks = makeBigBlocks(videoNo, bigBlockNo, blockNo, palleteNo, MapViewType.ObjType,MapViewType.Tiles, withBorders);
            int[] indexes = Globals.getScreen(ConfigScript.screensOffset[levelNo], scrNo);
            int   scrW    = ConfigScript.getScreenWidth(0); //zero as screenNoForLevel
            int   scrH    = ConfigScript.getScreenHeight(0);
            //capcom hardcode

            var blockLayer1 = new BlockLayer()
            {
                screens = new int[1][] { indexes }, showLayer = true, blockWidth = 32, blockHeight = 32
            };

            return(new Bitmap(MapEditor.ScreenToImage(bigBlocks, new BlockLayer[] { blockLayer1 }, 0, 2.0f, false, 0, 0, scrW, scrH)));
        }
コード例 #6
0
ファイル: Utils.cs プロジェクト: jonthomasson/NESGameOMatic
        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);
        }
コード例 #7
0
ファイル: Globals.cs プロジェクト: jonthomasson/NESGameOMatic
        //public static bool flushToFile()
        //{
        //    if (OpenFile.DumpName != "")
        //    {
        //        try
        //        {
        //            using (FileStream f = File.OpenWrite(OpenFile.DumpName))
        //            {
        //                f.Write(Globals.dumpdata, 0, Globals.dumpdata.Length);
        //                f.Seek(0, SeekOrigin.Begin);
        //            }
        //        }

        //        catch (Exception ex)
        //        {
        //            MessageBox.Show(ex.Message);
        //            return false;
        //        }
        //    }
        //    try
        //    {
        //        using (FileStream f = File.OpenWrite(OpenFile.FileName))
        //        {
        //            f.Write(Globals.romdata, 0, Globals.romdata.Length);
        //            f.Seek(0, SeekOrigin.Begin);
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        MessageBox.Show(ex.Message);
        //        return false;
        //    }
        //    return true;
        //}

        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);
        }
コード例 #8
0
        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);
        }
コード例 #9
0
ファイル: Utils.cs プロジェクト: jonthomasson/NESGameOMatic
        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];
                }
            }
        }
コード例 #10
0
ファイル: Utils.cs プロジェクト: jonthomasson/NESGameOMatic
        public static LevelLayerData getLayoutLinear(int curActiveLayout)
        {
            int layoutAddr = ConfigScript.getLayoutAddr(curActiveLayout);
            int scrollAddr = ConfigScript.getScrollAddr(curActiveLayout);
            int width      = ConfigScript.getLevelWidth(curActiveLayout);
            int height     = ConfigScript.getLevelHeight(curActiveLayout);

            int[] layer = new int[width * height];
            for (int i = 0; i < width * height; i++)
            {
                layer[i] = Globals.romdata[layoutAddr + i];
            }
            bool needScrolls = ConfigScript.getScrollsOffsetFromLayout() != 0;
            var  scrolls     = new int[width * height];

            if (needScrolls)
            {
                for (int i = 0; i < width * height; i++)
                {
                    scrolls[i] = Globals.romdata[scrollAddr + i];
                }
            }
            return(new LevelLayerData(width, height, layer, needScrolls ? scrolls : null, null));
        }
コード例 #11
0
 public static int getLevelHeight(int levelNo)
 {
     return(ConfigScript.getLevelRec(levelNo).height);
 }
コード例 #12
0
 public static int getScrollAddr(int index)
 {
     return(getLayoutAddr(index) + ConfigScript.getScrollsOffsetFromLayout());
 }
コード例 #13
0
 public static int getLevelWidth(int levelNo)
 {
     return(ConfigScript.getLevelRec(levelNo).width);
 }
コード例 #14
0
        public static void LoadFromFile(string fileName)
        {
            programStartDirectory = AppDomain.CurrentDomain.BaseDirectory + "/";
            configDirectory       = Path.GetDirectoryName(fileName) + "/";

            var    asm            = new AsmHelper(CSScript.LoadCode(File.ReadAllText(fileName)));
            object data           = null;
            bool   metaDataExists = true;

            try
            {
                object metaData = null;
                try
                {
                    metaData = asm.CreateObject("MetaData");
                }
                catch (Exception)
                {
                    metaDataExists = false;
                }
                if (metaDataExists)
                {
                    var scriptText = callFromScript(asm, metaData, "*.makeConfig", "");
                    var patchDict  = callFromScript(asm, metaData, "*.getPatchDictionary", new Dictionary <string, object>());
                    scriptText = Utils.patchConfigTemplate(scriptText, patchDict);
                    asm        = new AsmHelper(CSScript.LoadCode(scriptText));
                    data       = asm.CreateObject("Data");
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }

            if (!metaDataExists)
            {
                try
                {
                    data = asm.CreateObject("Data");
                }
                catch (Exception)
                {
                    return;
                }
            }

            levelsCount   = callFromScript(asm, data, "*.getLevelsCount", 1);
            screensOffset = new OffsetRec[levelsCount];

            palOffset               = callFromScript(asm, data, "*.getPalOffset", new OffsetRec(0, 1, 0));
            videoOffset             = callFromScript(asm, data, "*.getVideoOffset", new OffsetRec(0, 1, 0));
            videoObjOffset          = callFromScript(asm, data, "*.getVideoObjOffset", new OffsetRec(0, 1, 0));
            blocksOffset            = callFromScript(asm, data, "*.getBlocksOffset", new OffsetRec(0, 1, 0));
            screensOffset[0]        = callFromScript(asm, data, "*.getScreensOffset", new OffsetRec(0, 1, 0));
            screensOffset[0].width  = callFromScript(asm, data, "*.getScreenWidth", 8);
            screensOffset[0].height = callFromScript(asm, data, "*.getScreenHeight", 8);
            if ((screensOffset[0].beginAddr == 0) && (screensOffset[0].recSize == 0))
            {
                screensOffset = callFromScript(asm, data, "*.getScreensOffsetsForLevels", new OffsetRec[1]);
            }
            screensOffset2             = callFromScript(asm, data, "*.getScreensOffset2", new OffsetRec(0, 1, 0));
            screenVertical             = callFromScript(asm, data, "*.getScreenVertical", false);
            screenDataStride           = callFromScript(asm, data, "*.getScreenDataStride", 1);
            wordLen                    = callFromScript(asm, data, "*.getWordLen", 1);
            littleEndian               = callFromScript(asm, data, "*.isLittleEndian", false);
            useSegaGraphics            = callFromScript(asm, data, "*.isUseSegaGraphics", false);
            blockSize4x4               = callFromScript(asm, data, "*.isBlockSize4x4", false);
            buildScreenFromSmallBlocks = callFromScript(asm, data, "isBuildScreenFromSmallBlocks", false);
            layersCount                = callFromScript(asm, data, "*.getLayersCount", 1);
            levelRecs                  = callFromScript(asm, data, "*.getLevelRecs", new List <LevelRec>()
            {
                new LevelRec(0, 0, 1, 1, 0)
            });

            //todo: remove or change to many lists interface
            minObjCoordX = callFromScript(asm, data, "*.getMinObjCoordX", 0);
            minObjCoordY = callFromScript(asm, data, "*.getMinObjCoordY", 0);
            minObjType   = callFromScript(asm, data, "*.getMinObjType", 0);
            maxObjCoordX = callFromScript(asm, data, "*.getMaxObjCoordX", -1); //ConfigScript.getScreenWidth() * 32
            maxObjCoordY = callFromScript(asm, data, "*.getMaxObjCoordY", -1); //ConfigScript.getScreenHeight() * 32;
            maxObjType   = callFromScript(asm, data, "*.getMaxObjType", -1);   //256

            bigBlocksHierarchyCount = callFromScript <int>(asm, data, "*.getBigBlocksHierarchyCount", 1);

            bigBlocksCounts = new int[bigBlocksHierarchyCount];
            for (int hierLevel = 0; hierLevel < bigBlocksHierarchyCount; hierLevel++)
            {
                bigBlocksCounts[hierLevel] = callFromScript(asm, data, "*.getBigBlocksCountHierarchy", 256, hierLevel);
            }
            bigBlocksCounts[0] = callFromScript(asm, data, "*.getBigBlocksCount", bigBlocksCounts[0]);

            bigBlocksOffsets = new OffsetRec[bigBlocksHierarchyCount];
            for (int hierLevel = 0; hierLevel < bigBlocksHierarchyCount; hierLevel++)
            {
                bigBlocksOffsets[hierLevel] = callFromScript(asm, data, "*.getBigBlocksOffsetHierarchy", new OffsetRec(0, 1, 0), hierLevel);
            }
            bigBlocksOffsets[0] = callFromScript(asm, data, "*.getBigBlocksOffset", bigBlocksOffsets[0]);

            getVideoPageAddrFunc = callFromScript <GetVideoPageAddrFunc>(asm, data, "*.getVideoPageAddrFunc");
            getVideoChunkFunc    = callFromScript <GetVideoChunkFunc>(asm, data, "*.getVideoChunkFunc");
            setVideoChunkFunc    = callFromScript <SetVideoChunkFunc>(asm, data, "*.setVideoChunkFunc");

            getBigBlocksFuncs = new GetBigBlocksFunc[bigBlocksHierarchyCount];
            setBigBlocksFuncs = new SetBigBlocksFunc[bigBlocksHierarchyCount];
            getBigBlocksFuncs = callFromScript <GetBigBlocksFunc[]>(asm, data, "*.getBigBlocksFuncs", new GetBigBlocksFunc[1]);
            setBigBlocksFuncs = callFromScript <SetBigBlocksFunc[]>(asm, data, "*.setBigBlocksFuncs", new SetBigBlocksFunc[1]);
            if (!buildScreenFromSmallBlocks)
            {
                getBigBlocksFuncs[0] = callFromScript <GetBigBlocksFunc>(asm, data, "*.getBigBlocksFunc", getBigBlocksFuncs[0]);
                setBigBlocksFuncs[0] = callFromScript <SetBigBlocksFunc>(asm, data, "*.setBigBlocksFunc", setBigBlocksFuncs[0]);
            }

            getSegaMappingFunc         = callFromScript <GetSegaMappingFunc>(asm, data, "*.getSegaMappingFunc", (int index) => { return(Utils.readLinearBigBlockData(0, index)); });
            setSegaMappingFunc         = callFromScript <SetSegaMappingFunc>(asm, data, "*.setSegaMappingFunc", (int index, byte[] bb) => { Utils.writeLinearBigBlockData(0, index, bb); });
            getBlocksFunc              = callFromScript <GetBlocksFunc>(asm, data, "*.getBlocksFunc");
            setBlocksFunc              = callFromScript <SetBlocksFunc>(asm, data, "*.setBlocksFunc");
            getPalFunc                 = callFromScript <GetPalFunc>(asm, data, "*.getPalFunc");
            setPalFunc                 = callFromScript <SetPalFunc>(asm, data, "*.setPalFunc");
            getObjectsFunc             = callFromScript <GetObjectsFunc>(asm, data, "*.getObjectsFunc");
            setObjectsFunc             = callFromScript <SetObjectsFunc>(asm, data, "*.setObjectsFunc");
            sortObjectsFunc            = callFromScript <SortObjectsFunc>(asm, data, "*.sortObjectsFunc");
            getLayoutFunc              = callFromScript <GetLayoutFunc>(asm, data, "*.getLayoutFunc", Utils.getDefaultLayoutFunc());
            setLayoutFunc              = callFromScript <SetLayoutFunc>(asm, data, "*.setLayoutFunc", null);
            convertScreenTileFunc      = callFromScript <ConvertScreenTileFunc>(asm, data, "*.getConvertScreenTileFunc");
            backConvertScreenTileFunc  = callFromScript <ConvertScreenTileFunc>(asm, data, "*.getBackConvertScreenTileFunc");
            getBigTileNoFromScreenFunc = callFromScript <GetBigTileNoFromScreenFunc>(asm, data, "*.getBigTileNoFromScreenFunc", Utils.getBigTileNoFromScreen);
            setBigTileToScreenFunc     = callFromScript <SetBigTileToScreenFunc>(asm, data, "*.setBigTileToScreenFunc", Utils.setBigTileToScreen);
            getObjectDictionaryFunc    = callFromScript <GetObjectDictionaryFunc>(asm, data, "*.getObjectDictionaryFunc");
            loadSegaBackFunc           = callFromScript <LoadSegaBackFunc>(asm, data, "*.loadSegaBackFunc");
            saveSegaBackFunc           = callFromScript <SaveSegaBackFunc>(asm, data, "*.saveSegaBackFunc");
            segaBackWidth              = callFromScript(asm, data, "*.getSegaBackWidth", 64);
            segaBackHeight             = callFromScript(asm, data, "*.getSegaBackHeight", 32);

            drawObjectFunc    = callFromScript <DrawObjectFunc>(asm, data, "*.getDrawObjectFunc");
            drawObjectBigFunc = callFromScript <DrawObjectBigFunc>(asm, data, "*.getDrawObjectBigFunc");

            renderToMainScreenFunc = callFromScript <RenderToMainScreenFunc>(asm, data, "*.getRenderToMainScreenFunc");

            isBigBlockEditorEnabled = callFromScript(asm, data, "*.isBigBlockEditorEnabled", true);
            isBlockEditorEnabled    = callFromScript(asm, data, "*.isBlockEditorEnabled", true);
            isEnemyEditorEnabled    = callFromScript(asm, data, "*.isEnemyEditorEnabled", true);
            objTypesPicturesDir     = callFromScript(asm, data, "*.getObjTypesPicturesDir", "obj_sprites");

            showScrollsInLayout     = callFromScript(asm, data, "*.isShowScrollsInLayout", true);
            scrollsOffsetFromLayout = callFromScript(asm, data, "*.getScrollsOffsetFromLayout", 0);

            blocksCount = callFromScript(asm, data, "*.getBlocksCount", 256);

            blocksPicturesFilename = callFromScript(asm, data, "getBlocksFilename", "");
            if (blocksPicturesFilename != "")
            {
                if (!File.Exists(ConfigScript.getBlocksPicturesFilename()))
                {
                    throw new Exception("File does not exists: " + ConfigScript.getBlocksPicturesFilename());
                }
            }
            blocksPicturesWidth     = callFromScript(asm, data, "getPictureBlocksWidth", 32);
            usePicturesInstedBlocks = blocksPicturesFilename != "";

            blockTypeNames = callFromScript(asm, data, "getBlockTypeNames", defaultBlockTypeNames);

            groups = callFromScript(asm, data, "getGroups", new GroupRec[0]);

            palBytesAddr = callFromScript(asm, data, "getPalBytesAddr", -1);

            loadAllPlugins(asm, data);
        }
コード例 #15
0
 public static int getLayoutAddr(int index)
 {
     return(ConfigScript.getLevelRec(index).layoutAddr);
 }
コード例 #16
0
ファイル: Utils.cs プロジェクト: jonthomasson/NESGameOMatic
 public static ObjRec[] getBlocksFromTiles16Pal1(int blockIndex)
 {
     return(readBlocksLinearTiles16Pal1(Globals.romdata, ConfigScript.getTilesAddr(blockIndex), ConfigScript.getPalBytesAddr(), ConfigScript.getBlocksCount()));
 }
コード例 #17
0
        public static void Render(Graphics g, Image[] bigBlocks, Rectangle?visibleRect, BlockLayer[] layers, int scrNo, float CurScale, bool ShowBorder, bool showBlocksAxis, int LeftMargin, int TopMargin, int WIDTH, int HEIGHT)
        {
            g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
            g.PixelOffsetMode   = System.Drawing.Drawing2D.PixelOffsetMode.Half;

            bool verticalScreen = ConfigScript.getScreenVertical();
            int  SIZE           = WIDTH * HEIGHT;

            for (int layerIndex = 0; layerIndex < layers.Length; layerIndex++)
            {
                var  layer           = layers[layerIndex];
                bool needRenderLayer = layer != null && layer.screens != null && layer.screens[scrNo] != null && layer.showLayer;
                if (!needRenderLayer)
                {
                    continue;
                }

                int TILE_SIZE_X = (int)(layer.blockWidth * CurScale);
                int TILE_SIZE_Y = (int)(layer.blockHeight * CurScale);

                for (int i = 0; i < SIZE; i++)
                {
                    int       bigBlockNo = ConfigScript.getBigTileNoFromScreen(layer.screens[scrNo], i);
                    Rectangle tileRect;
                    if (verticalScreen)
                    {
                        tileRect = new Rectangle(i / WIDTH * TILE_SIZE_X + LeftMargin, (i % WIDTH) * TILE_SIZE_Y + TopMargin, TILE_SIZE_X, TILE_SIZE_Y);
                    }
                    else
                    {
                        tileRect = new Rectangle((i % WIDTH) * TILE_SIZE_X + LeftMargin, i / WIDTH * TILE_SIZE_Y + TopMargin, TILE_SIZE_X, TILE_SIZE_Y);
                    }

                    if (visibleRect == null || visibleRect.Value.Contains(tileRect) || visibleRect.Value.IntersectsWith(tileRect))
                    {
                        if (bigBlockNo > -1 && bigBlockNo < bigBlocks.Length)
                        {
                            g.DrawImage(bigBlocks[bigBlockNo], tileRect);
                            if (showBlocksAxis)
                            {
                                g.DrawRectangle(new Pen(Color.FromArgb(255, 255, 255, 255)), tileRect);
                            }
                        }
                        //else
                        //    g.FillRectangle(Brushes.White, tileRect);
                    }
                }
            }

            if (ShowBorder)
            {
                int TILE_SIZE_X = (int)(layers[0].blockWidth * CurScale);
                int TILE_SIZE_Y = (int)(layers[0].blockHeight * CurScale);
                if (verticalScreen)
                {
                    g.DrawRectangle(new Pen(Color.Green, 4.0f), new Rectangle(0, TILE_SIZE_Y, TILE_SIZE_X * HEIGHT, TILE_SIZE_Y * WIDTH));
                }
                else
                {
                    g.DrawRectangle(new Pen(Color.Green, 4.0f), new Rectangle(TILE_SIZE_X, 0, TILE_SIZE_X * WIDTH, TILE_SIZE_Y * HEIGHT));
                }
            }

            //Additional rendering  //float to int!
            ConfigScript.renderToMainScreen(g, (int)CurScale);
        }
コード例 #18
0
 /// <summary>
 /// Loads data for selected game and level
 /// </summary>
 private void InitGlobalData()
 {
     Globals.loadData(FileName, "", ConfigName);
     ScreenHeight = ConfigScript.getScreenHeight(0);
     ScreenWidth  = ConfigScript.getScreenWidth(0);
 }
コード例 #19
0
ファイル: Utils.cs プロジェクト: jonthomasson/NESGameOMatic
 public static void setBlocksFromTiles16Pal1(int blockIndex, ObjRec[] blocksData)
 {
     writeBlocksLinearTiles16Pal1(blocksData, Globals.romdata, ConfigScript.getTilesAddr(blockIndex), ConfigScript.getPalBytesAddr(), ConfigScript.getBlocksCount());
 }
コード例 #20
0
ファイル: Utils.cs プロジェクト: jonthomasson/NESGameOMatic
 public static ObjRec[] getBlocksLinear4x2withoutAttrib(int blockIndex)
 {
     return(Utils.readBlocksLinear(Globals.romdata, ConfigScript.getTilesAddr(blockIndex), 4, 2, ConfigScript.getBlocksCount(), false));
 }
コード例 #21
0
ファイル: Utils.cs プロジェクト: jonthomasson/NESGameOMatic
 public static void setBlocksLinearWithoutAttrib(int blockIndex, ObjRec[] blocksData)
 {
     writeBlocksLinear(blocksData, Globals.romdata, ConfigScript.getTilesAddr(blockIndex), ConfigScript.getBlocksCount(), false);
 }
コード例 #22
0
 public Image[] makeBigBlocks(int videoNo, int bigBlockNo, int blockNo, int palleteNo, MapViewType smallObjectsViewType = MapViewType.Tiles,
                              MapViewType curViewType = MapViewType.Tiles, int hierarchyLevel = 0)
 {
     BigBlock[] bigBlockIndexes = ConfigScript.getBigBlocksRecursive(hierarchyLevel, blockNo);
     return(makeBigBlocks(videoNo, bigBlockNo, bigBlockIndexes, palleteNo, smallObjectsViewType, curViewType, hierarchyLevel));
 }