Esempio n. 1
0
        public SaveJson(string path, string romPath, RoomSave[] all_rooms, MapSave[] all_maps, Entrance[] entrances, string[] texts, Overworld overworld)
        {
            this.all_rooms = all_rooms;
            this.all_maps  = all_maps;
            this.entrances = entrances;
            this.texts     = texts;
            this.overworld = overworld;
            //TODO : Change Header location to be dynamic instead of static
            getLargeMaps();

            //ZipArchive zipfile = new ZipArchive(new FileStream("PROJECTFILE.zip", FileMode.Open), ZipArchiveMode.Create);

            string ProjectDirectorySlash = path + "\\";

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            //File.WriteAllText(ProjectDirectorySlash + "Main.cfg", writeProjectConfig());
            string[] text = new string[1];
            text[0] = "";
            //File.WriteAllText(ProjectDirectorySlash + "Project.zscr", writeProjectConfig());
            File.WriteAllText(ProjectDirectorySlash + "Project.zscr", JsonConvert.SerializeObject(text));

            writeRooms(ProjectDirectorySlash);
            writeEntrances(ProjectDirectorySlash);
            writeOverworldEntrances(ProjectDirectorySlash);
            writeOverworldExits(ProjectDirectorySlash);
            writeOverworldHoles(ProjectDirectorySlash);
            writeText(ProjectDirectorySlash);
            writePalettes(ProjectDirectorySlash);
            writeGfx(ProjectDirectorySlash);
            writeOverworldTiles16(ProjectDirectorySlash);
            writeOverworldMaps(ProjectDirectorySlash);
            writeOverworldConfig(ProjectDirectorySlash);
            writeOverworldGroups(ProjectDirectorySlash);
            writeOverworldGroups2(ProjectDirectorySlash);
            writeOverworldSpriteset(ProjectDirectorySlash);
            writeOverworldSprites(ProjectDirectorySlash);
            writeOverworldItems(ProjectDirectorySlash);
            writeOverworldTilesType(ProjectDirectorySlash);
            writeOverlays(ProjectDirectorySlash);
            writeASMstuff(ProjectDirectorySlash, romPath);
            writeTransportstuff(ProjectDirectorySlash);
        }
Esempio n. 2
0
        //public List<Room_Sprite> sprites;
        //public List<roomPotSave> items;
        public MapSave(short id, Overworld overworld)
        {
            tiles               = new ushort[32, 32];
            largeMap            = false;
            this.index          = id;
            this.palette        = (byte)(ROM.DATA[ConstantsReader.GetAddress("overworldMapPalette") + index] << 2);
            this.blockset       = ROM.DATA[ConstantsReader.GetAddress("mapGfx") + index];
            this.tileTypeSet    = ROM.DATA[0x1EF800 + index]; //all 0 by default so that's fine
            this.sprite_palette = (byte)(ROM.DATA[ConstantsReader.GetAddress("overworldSpritePalette") + index]);
            this.msgid          = (short)((ROM.DATA[(ConstantsReader.GetAddress("overworldMessages") + index * 2) + 1] << 8) + ROM.DATA[(ConstantsReader.GetAddress("overworldMessages") + index * 2)]);
            if (index != 0x80)
            {
                if (index <= 150)
                {
                    if (ROM.DATA[ConstantsReader.GetAddress("overworldMapSize") + (index & 0x3F)] != 0)
                    {
                        largeMap = true;
                    }
                }
            }

            this.spriteset = ROM.DATA[ConstantsReader.GetAddress("overworldSpriteset") + index];
            this.name      = ROMStructure.mapsNames[index];

            /*sprites = new List<Room_Sprite>();
             * int address = 0;
             * if (index < 0x40)
             * {
             *  address = ConstantsReader.GetAddress("overworldSpritesLW");
             *  }
             * else
             * {
             *  address = ConstantsReader.GetAddress("overworldSpritesDW");
             *  }
             * //09 bank ? Need to check if HM change that
             * int sprite_address_snes = (09 << 16) +
             * (ROM.DATA[address + (index * 2) + 1] << 8) +
             * ROM.DATA[address + (index * 2)];
             * int sprite_address = Addresses.snestopc(sprite_address_snes);
             *
             * while (true)
             * {
             *  byte b1 = ROM.DATA[sprite_address];
             *  byte b2 = ROM.DATA[sprite_address + 1];
             *  byte b3 = ROM.DATA[sprite_address + 2];
             *
             *  if (b1 == 0xFF) { break; }
             *
             *  sprites.Add(new Room_Sprite(b3, (byte)(b2 & 0x3F), (byte)(b1 & 0x3F), Sprites_Names.name[b3], 0, 0, 0, 0));
             *  sprite_address += 3;
             * }
             *
             *
             * items = new List<roomPotSave>();
             *
             * int addr = (ConstantsReader.GetAddress("overworldItemsBank") << 16) +
             *          (ROM.DATA[ConstantsReader.GetAddress("overworldItemsPointers") + (index * 2) + 1] << 8) +
             *          (ROM.DATA[ConstantsReader.GetAddress("overworldItemsPointers") + (index * 2)]);
             *
             * addr = Addresses.snestopc(addr);
             *
             * while (true)
             * {
             *  byte b1 = ROM.DATA[addr];
             *  byte b2 = ROM.DATA[addr + 1];
             *  byte b3 = ROM.DATA[addr + 2];
             *  if (b1 == 0xFF && b2 == 0xFF)
             *  {
             *      break;
             *  }
             *
             *  int p = (((b2 & 0x1F) << 8) + b1) >> 1;
             *
             *  int x = p % 64;
             *  int y = p >> 6;
             *
             *  items.Add(new roomPotSave(b3, (byte)x, (byte)y, false));
             *  addr += 3;
             * }
             */

            int t = index * 256;

            for (int y = 0; y < 16; y++)
            {
                for (int x = 0; x < 16; x++)
                {
                    tiles[(x * 2), (y * 2)]         = overworld.map16tiles[t].tile0;
                    tiles[(x * 2) + 1, (y * 2)]     = overworld.map16tiles[t].tile1;
                    tiles[(x * 2), (y * 2) + 1]     = overworld.map16tiles[t].tile2;
                    tiles[(x * 2) + 1, (y * 2) + 1] = overworld.map16tiles[t].tile3;
                    t++;
                }
            }
        }