示例#1
0
        public void LoadOverworldTiles()
        {
            overworld.AssembleMap16Tiles(true, path);
            int palettesOW_Addr       = ConstantsReader.GetAddress("overworldMapPalette");
            int spritepalettesOW_Addr = ConstantsReader.GetAddress("overworldSpritePalette");
            int spritesetOW_Addr      = ConstantsReader.GetAddress("overworldSpriteset");
            int mapsizeOW_Addr        = ConstantsReader.GetAddress("overworldMapSize");
            int messageOW_Addr        = ConstantsReader.GetAddress("overworldMessages");
            int blocksetOW_Addr       = ConstantsReader.GetAddress("mapGfx");



            for (int i = 0; i < 160; i++)
            {
                all_maps[i] = JsonConvert.DeserializeObject <MapSave>(File.ReadAllText(path + @"//Overworld//Maps//Map" + i.ToString("D3") + ".json"));

                overworld.AllMapTilesFromMap(i, all_maps[i].tiles);
                if (i == 159)
                {
                    string s    = "";
                    int    tpos = 0;
                    for (int y = 0; y < 16; y++)
                    {
                        for (int x = 0; x < 16; x++)
                        {
                            Tile32 map16 = new Tile32(all_maps[i].tiles[(x * 2), (y * 2)], all_maps[i].tiles[(x * 2) + 1, (y * 2)], all_maps[i].tiles[(x * 2), (y * 2) + 1], all_maps[i].tiles[(x * 2) + 1, (y * 2) + 1]);
                            s += "[" + map16.tile0.ToString("D4") + "," + map16.tile1.ToString("D4") + "," + map16.tile2.ToString("D4") + "," + map16.tile3.ToString("D4") + "] ";
                            tpos++;
                        }
                        s += "\r\n";
                    }
                    //File.WriteAllText("TileDebug2.txt", s);
                }
            }

            for (int i = 0; i < 136; i++)
            {
                //Need to finish importing stuff here !
                ROM.DATA[(0x1EF800 + DataOffset) + i] = all_maps[i].tileTypeSet;


                ROM.DATA[palettesOW_Addr + i]          = (byte)(all_maps[i].palette >> 2); // why the >> 2 ¯\_(ツ)_/¯
                ROM.DATA[blocksetOW_Addr + i]          = all_maps[i].blockset;
                ROM.DATA[spritesetOW_Addr + i]         = all_maps[i].spriteset;
                ROM.DATA[spritepalettesOW_Addr + i]    = all_maps[i].sprite_palette;
                ROM.DATA[messageOW_Addr + (i * 2) + 1] = (byte)((all_maps[i].msgid >> 8) & 0xFF);
                ROM.DATA[messageOW_Addr + (i * 2)]     = (byte)(all_maps[i].msgid & 0xFF);
            }
            //ROM.DATA[mapsizeOW_Addr + i] = (byte)(all_maps[i].largeMap?0:1);
            byte[] largemaps = getLargeMaps();
            //overworld.createMap32TilesFrom16();
            //overworld.savemapstorom();
            overworld.savemapstoromNEW(all_maps);

            //WriteLog("Overworld tiles data loaded properly", Color.Green);
        }
示例#2
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);
        }
示例#3
0
        public void createMap32TilesFrom16()
        {
            t32.Clear();
            t32Unique    = new Tile32[10000];
            tiles32count = 0;
            //40960 = numbers of 32x32 tiles

            const int nullVal = -1;

            for (int i = 0; i < 40960; i++)
            {
                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);
        }
示例#4
0
        public void DecompressAllMapTiles()
        {
            //locat functions
            int genPointer(int address, int i) => PointerRead.LongRead_LoHiBank(address + i * 3);

            byte[] Decomp(int pointer, ref int compressedSize)
            => Decompress.ALTTPDecompressOverworld(ROM.DATA, pointer, 1000, ref compressedSize);

            int npos = 0;

            for (int i = 0; i < 160; i++)
            {
                int p1 = genPointer(ConstantsReader.GetAddress("compressedAllMap32PointersHigh"), i),
                    p2 = genPointer(ConstantsReader.GetAddress("compressedAllMap32PointersLow"), i);

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

                byte[]
                bytes = Decomp(p2, ref compressedSize1),
                bytes2 = Decomp(p1, ref compressedSize2);

                for (int y = 0; y < 16; y++)
                {
                    for (int x = 0, tpos; x < 16; x++, npos++, ttpos++)
                    {
                        tpos = (ushort)((bytes2[ttpos] << 8) + bytes[ttpos]);
                        if (tpos < tiles32.Count)
                        {
                            map16tiles[npos] = new Tile32(tiles32[tpos].tile0, tiles32[tpos].tile1, tiles32[tpos].tile2, tiles32[tpos].tile3);
                        }
                        else
                        {
                            Console.WriteLine("Found 0,0,0,0");
                            map16tiles[npos] = new Tile32(0, 0, 0, 0);
                        }
                    }
                }
            }
        }