Esempio n. 1
0
 public static void AllMapTilesFromMap(int mapid, ushort[,] tiles, bool large = false)
 {
     if (large == true)
     {
         int tpos = mapid * 256;
         for (int y = 0; y < 16; y++)
         {
             for (int x = 0; x < 16; x++)
             {
                 map16tiles[tpos] = new Tile32(tiles[(x * 2), (y * 2)], tiles[(x * 2) + 1, (y * 2)], tiles[(x * 2), (y * 2) + 1], tiles[(x * 2) + 1, (y * 2) + 1]);
                 tpos++;
             }
         }
         tpos = ((mapid + 1) * 256);
         for (int y = 0; y < 16; y++)
         {
             for (int x = 16; x < 32; x++)
             {
                 map16tiles[tpos] = new Tile32(tiles[(x * 2), (y * 2)], tiles[(x * 2) + 1, (y * 2)], tiles[(x * 2), (y * 2) + 1], tiles[(x * 2) + 1, (y * 2) + 1]);
                 tpos++;
             }
         }
         tpos = ((mapid + 8) * 256);
         for (int y = 16; y < 32; y++)
         {
             for (int x = 0; x < 16; x++)
             {
                 map16tiles[tpos] = new Tile32(tiles[(x * 2), (y * 2)], tiles[(x * 2) + 1, (y * 2)], tiles[(x * 2), (y * 2) + 1], tiles[(x * 2) + 1, (y * 2) + 1]);
                 tpos++;
             }
         }
         tpos = ((mapid + 9) * 256);
         for (int y = 16; y < 32; y++)
         {
             for (int x = 16; x < 32; x++)
             {
                 map16tiles[tpos] = new Tile32(tiles[(x * 2), (y * 2)], tiles[(x * 2) + 1, (y * 2)], tiles[(x * 2), (y * 2) + 1], tiles[(x * 2) + 1, (y * 2) + 1]);
                 tpos++;
             }
         }
     }
     else
     {
         int tpos = mapid * 256;
         for (int y = 0; y < 16; y++)
         {
             for (int x = 0; x < 16; x++)
             {
                 map16tiles[tpos] = new Tile32(tiles[(x * 2), (y * 2)], tiles[(x * 2) + 1, (y * 2)], tiles[(x * 2), (y * 2) + 1], tiles[(x * 2) + 1, (y * 2) + 1]);
                 tpos++;
             }
         }
     }
 }
Esempio n. 2
0
        public static void DecompressAllMapTiles()
        {
            int npos = 0;

            for (int i = 0; i < 160; i++)
            {
                int p1 =
                    (ROM.DATA[(Constants.compressedAllMap32PointersHigh) + 2 + (int)(3 * i)] << 16) +
                    (ROM.DATA[(Constants.compressedAllMap32PointersHigh) + 1 + (int)(3 * i)] << 8) +
                    (ROM.DATA[(Constants.compressedAllMap32PointersHigh + (int)(3 * i))]);
                p1 = Addresses.snestopc(p1);

                int p2 =
                    (ROM.DATA[(Constants.compressedAllMap32PointersLow) + 2 + (int)(3 * i)] << 16) +
                    (ROM.DATA[(Constants.compressedAllMap32PointersLow) + 1 + (int)(3 * i)] << 8) +
                    (ROM.DATA[(Constants.compressedAllMap32PointersLow + (int)(3 * i))]);
                p2 = Addresses.snestopc(p2);

                int ttpos           = 0;
                int compressedSize1 = 0;
                int compressedSize2 = 0;


                byte[] bytes  = ZCompressLibrary.Decompress.ALTTPDecompressOverworld(ROM.DATA, p2, 1000, ref compressedSize1);
                byte[] bytes2 = ZCompressLibrary.Decompress.ALTTPDecompressOverworld(ROM.DATA, p1, 1000, ref compressedSize2);

                for (int y = 0; y < 16; y++)
                {
                    for (int x = 0; x < 16; x++)
                    {
                        ushort tidD = (ushort)((bytes2[ttpos] << 8) + bytes[ttpos]);

                        int tpos = tidD;
                        if (tpos < GFX.tiles32.Count)
                        {
                            map16tiles[npos] = new Tile32(GFX.tiles32[tpos].tile0, GFX.tiles32[tpos].tile1, GFX.tiles32[tpos].tile2, GFX.tiles32[tpos].tile3);
                        }
                        else
                        {
                            map16tiles[npos] = new Tile32(0, 0, 0, 0);
                        }
                        if (i == 0)
                        {
                            //Console.Write(tpos + ",");
                        }
                        npos++;
                        ttpos += 1;
                    }
                }
            }
        }
Esempio n. 3
0
        //UNUSED CODE
        public void AllMapTilesFromMap(int mapid, ushort[,] tiles, bool large = false)
        {
            string s    = "";
            int    tpos = mapid * 256;

            for (int y = 0; y < 16; y++)
            {
                for (int x = 0; x < 16; x++)
                {
                    map16tiles[tpos] = new Tile32(tiles[(x * 2), (y * 2)], tiles[(x * 2) + 1, (y * 2)], tiles[(x * 2), (y * 2) + 1], tiles[(x * 2) + 1, (y * 2) + 1]);
                    //s += "[" + map16tiles[tpos].tile0.ToString("D4") + "," + map16tiles[tpos].tile1.ToString("D4") + "," + map16tiles[tpos].tile2.ToString("D4") + "," + map16tiles[tpos].tile3.ToString("D4") + "] ";
                    tpos++;
                }
                s += "\r\n";
            }
            //File.WriteAllText("TileDebug.txt", s);
        }
Esempio n. 4
0
        public void createMap32TilesFrom16()
        {
            t32.Clear();
            tiles32count = 0;


            const int nullVal = -1;

            for (int i = 0; i < 40960; i++) //40960 = numbers of 32x32 tiles
            {
                short foundIndex = nullVal;
                for (int j = 0; j < tiles32count; j++)
                {
                    if (t32Unique[j].tile0 == map16tiles[i].tile0)
                    {
                        if (t32Unique[j].tile1 == map16tiles[i].tile1)
                        {
                            if (t32Unique[j].tile2 == map16tiles[i].tile2)
                            {
                                if (t32Unique[j].tile3 == map16tiles[i].tile3)
                                {
                                    foundIndex = (short)j;
                                    break;
                                }
                            }
                        }
                    }
                }


                if (foundIndex == nullVal)
                {
                    t32Unique[tiles32count] = new Tile32(map16tiles[i].tile0, map16tiles[i].tile1, map16tiles[i].tile2, map16tiles[i].tile3);
                    t32.Add((ushort)tiles32count);
                    tiles32count++;
                }
                else
                {
                    t32.Add((ushort)foundIndex);
                }
            }

            Console.WriteLine("Nbr of tiles32 = " + tiles32count);
        }