Ejemplo n.º 1
0
        public static MapData loadMapFromBlocks(int mapNo, int mapSizeInBytes, int attrSizeInBytes, int mapWidth, bool vertical, FillAttribDelegate fillAttribDelegate)
        {
            int romAddr    = MapConfig.mapsInfo[mapNo].dataAddr;
            int attribAddr = MapConfig.mapsInfo[mapNo].attribsAddr;

            int[] mapData  = new int[mapSizeInBytes];
            int[] attrData = new int[attrSizeInBytes];
            var   blocks   = ConfigScript.getBlocks(0);
            int   scrSize  = ConfigScript.getScreenWidth(0) * ConfigScript.getScreenHeight(0);

            //fill tiles region
            int SCREEN_WIDTH = ConfigScript.getScreenWidth(0);

            for (int i = 0; i < scrSize; i++)
            {
                int blockIndex = Globals.readBlockIndexFromMap(Globals.romdata, romAddr, i);
                int bx         = i % SCREEN_WIDTH;
                int by         = i / SCREEN_WIDTH;
                if (vertical)
                {
                    Utils.Swap(ref bx, ref by);
                }
                applyBlockToMap(mapData, blocks[blockIndex], bx, by, mapWidth);
            }

            fillAttribDelegate(attrData, Globals.romdata, attribAddr);
            return(new MapData(mapData, attrData, mapWidth));
        }
Ejemplo n.º 2
0
        public static MapData[] loadMapFromBlocks(int mapNo, int mapSizeInBytes, int attrSizeInBytes, int mapWidth, bool vertical, FillAttribDelegate fillAttribDelegate, int yShiftInTiles = 0)
        {
            int romAddr    = MapConfig.mapsInfo[mapNo].dataAddr;
            int attribAddr = MapConfig.mapsInfo[mapNo].attribsAddr;

            int[] mapData  = new int[mapSizeInBytes];
            int[] attrData = new int[attrSizeInBytes];
            var   blocks   = ConfigScript.getBlocks(0);

            var screens = ConfigScript.loadScreens();
            var screen  = screens[mapNo];
            int scrSize = screen.width * screen.height;

            //fill tiles region
            int screenWidth  = screen.width;
            var blockIndexes = new int[scrSize];

            for (int i = 0; i < scrSize; i++)
            {
                blockIndexes[i] = Globals.readBlockIndexFromMap(Globals.romdata, romAddr, i);
            }

            if (vertical)
            {
                blockIndexes = Utils.transpose(blockIndexes, screenWidth, screen.height);
            }
            for (int i = 0; i < scrSize; i++)
            {
                int bx = i % screenWidth;
                int by = i / screenWidth;
                applyBlockToMap(mapData, blocks[blockIndexes[i]], bx, by, mapWidth, yShiftInTiles);
            }

            fillAttribDelegate(attrData, Globals.romdata, attribAddr);
            return(new[] { new MapData(mapData, attrData, mapWidth) });
        }