public void AssembleMap32Tiles() { map32address = new int[] { ConstantsReader.GetAddress("map32TilesTL"), ConstantsReader.GetAddress("map32TilesTR"), ConstantsReader.GetAddress("map32TilesBL"), ConstantsReader.GetAddress("map32TilesBR") }; const int dim = 4; for (int i = 0; i < 0x33F0; i += 6) { ushort[,] b = new ushort[dim, dim]; ushort tl, tr, bl, br; for (int k = 0; k < 4; k++) { tl = generate(i, k, (int)Dimension.map32TilesTL); tr = generate(i, k, (int)Dimension.map32TilesTR); bl = generate(i, k, (int)Dimension.map32TilesBL); br = generate(i, k, (int)Dimension.map32TilesBR); tiles32.Add(new Tile32(tl, tr, bl, br)); } } }
public indoor_blocks() : base(4) { primaryPointer_location = new int[] { ConstantsReader.GetAddress("blocks_pointer1"), ConstantsReader.GetAddress("blocks_pointer2"), ConstantsReader.GetAddress("blocks_pointer3"), ConstantsReader.GetAddress("blocks_pointer4") }; //maxBytesPerBlockFor012 = ReadMixedNumbers.readTwoByte(addressOfStorageMaxFor012); maxBytesPerBlockFor012 = 0x80; dataSize = new int[] { maxBytesPerBlockFor012, maxBytesPerBlockFor012, maxBytesPerBlockFor012, maxBytesPerBlockFor3 }; for (int i = 0; i < numberOfPointers; i++) { sizeOfBlockData += dataSize[i]; } maxBlockEntries = sizeOfBlockData / bytesPerBlock; refreshPointer3Bytes(); }
public void writeOverworldExits(string path) { if (!Directory.Exists(path + "Overworld")) { Directory.CreateDirectory(path + "Overworld"); } if (!Directory.Exists(path + "Overworld//Exits")) { Directory.CreateDirectory(path + "Overworld//Exits"); } for (int i = 0; i < 0x4F; i++) { short[] e = new short[13]; e[0] = (short)((ROM.DATA[ConstantsReader.GetAddress("OWExitRoomId") + (i * 2) + 1] << 8) + (ROM.DATA[ConstantsReader.GetAddress("OWExitRoomId") + (i * 2)])); e[1] = (byte)((ROM.DATA[ConstantsReader.GetAddress("OWExitMapId") + i])); e[2] = (short)((ROM.DATA[ConstantsReader.GetAddress("OWExitVram") + (i * 2) + 1] << 8) + (ROM.DATA[ConstantsReader.GetAddress("OWExitVram") + (i * 2)])); e[3] = (short)((ROM.DATA[ConstantsReader.GetAddress("OWExitYScroll") + (i * 2) + 1] << 8) + (ROM.DATA[ConstantsReader.GetAddress("OWExitYScroll") + (i * 2)])); e[4] = (short)((ROM.DATA[ConstantsReader.GetAddress("OWExitXScroll") + (i * 2) + 1] << 8) + (ROM.DATA[ConstantsReader.GetAddress("OWExitXScroll") + (i * 2)])); e[5] = (short)((ROM.DATA[ConstantsReader.GetAddress("OWExitYPlayer") + (i * 2) + 1] << 8) + (ROM.DATA[ConstantsReader.GetAddress("OWExitYPlayer") + (i * 2)])); e[6] = (short)((ROM.DATA[ConstantsReader.GetAddress("OWExitXPlayer") + (i * 2) + 1] << 8) + (ROM.DATA[ConstantsReader.GetAddress("OWExitXPlayer") + (i * 2)])); e[7] = (short)((ROM.DATA[ConstantsReader.GetAddress("OWExitYCamera") + (i * 2) + 1] << 8) + (ROM.DATA[ConstantsReader.GetAddress("OWExitYCamera") + (i * 2)])); e[8] = (short)((ROM.DATA[ConstantsReader.GetAddress("OWExitXCamera") + (i * 2) + 1] << 8) + (ROM.DATA[ConstantsReader.GetAddress("OWExitXCamera") + (i * 2)])); e[9] = (byte)((ROM.DATA[ConstantsReader.GetAddress("OWExitUnk1") + i])); e[10] = (byte)((ROM.DATA[ConstantsReader.GetAddress("OWExitUnk2") + i])); e[11] = (byte)((ROM.DATA[ConstantsReader.GetAddress("OWExitDoorType1") + i])); e[12] = (byte)((ROM.DATA[ConstantsReader.GetAddress("OWExitDoorType2") + i])); ExitOW eo = (new ExitOW(e[0], (byte)e[1], e[2], e[3], e[4], e[5], e[6], e[7], e[8], (byte)e[9], (byte)e[10], (byte)e[11], (byte)e[12])); File.WriteAllText(path + "Overworld//Exits//Exit" + i.ToString("D3") + ".json", JsonConvert.SerializeObject(eo)); } }
public void addlistBlock(ref byte[] blocksdata, int maxCount) { int pos1 = (ROM.DATA[ConstantsReader.GetAddress("blocks_pointer1") + 2] << 16) + (ROM.DATA[ConstantsReader.GetAddress("blocks_pointer1") + 1] << 8) + (ROM.DATA[ConstantsReader.GetAddress("blocks_pointer1")]); pos1 = Addresses.snestopc(pos1); int pos2 = (ROM.DATA[ConstantsReader.GetAddress("blocks_pointer2") + 2] << 16) + (ROM.DATA[ConstantsReader.GetAddress("blocks_pointer2") + 1] << 8) + (ROM.DATA[ConstantsReader.GetAddress("blocks_pointer2")]); pos2 = Addresses.snestopc(pos2); int pos3 = (ROM.DATA[ConstantsReader.GetAddress("blocks_pointer3") + 2] << 16) + (ROM.DATA[ConstantsReader.GetAddress("blocks_pointer3") + 1] << 8) + (ROM.DATA[ConstantsReader.GetAddress("blocks_pointer3")]); pos3 = Addresses.snestopc(pos3); int pos4 = (ROM.DATA[ConstantsReader.GetAddress("blocks_pointer4") + 2] << 16) + (ROM.DATA[ConstantsReader.GetAddress("blocks_pointer4") + 1] << 8) + (ROM.DATA[ConstantsReader.GetAddress("blocks_pointer4")]); pos4 = Addresses.snestopc(pos4); for (int i = 0; i < 0x80; i += 1) { blocksdata[i] = (ROM.DATA[i + pos1]); blocksdata[i + 0x80] = (ROM.DATA[i + pos2]); if (i + 0x100 < maxCount) { blocksdata[i + 0x100] = (ROM.DATA[i + pos3]); } if (i + 0x180 < maxCount) { blocksdata[i + 0x180] = (ROM.DATA[i + pos4]); } } }
public void addBlocks() { //288 int blocksCount = (short)((ROM.DATA[ConstantsReader.GetAddress("blocks_length") + 1] << 8) + ROM.DATA[ConstantsReader.GetAddress("blocks_length")]); byte[] blocksdata = new byte[blocksCount]; //int blocksCount = (short)((ROM.DATA[ConstantsReader.GetAddress("blocks_length + 1] << 8) + ROM.DATA[ConstantsReader.GetAddress("blocks_length]); addlistBlock(ref blocksdata, blocksCount); for (int i = 0; i < blocksCount; i += 4) { byte b1 = blocksdata[i], b2 = blocksdata[i + 1], b3 = blocksdata[i + 2], b4 = blocksdata[i + 3]; if (((b2 << 8) + b1) == index) { if (b3 == 0xFF && b4 == 0xFF) { break; } int address = ((b4 & 0x1F) << 8 | b3) >> 1; int px = address % 64; int py = address >> 6; blocks.Add(new Room_Blocks(0x0E00, (byte)(px), (byte)(py), 0, (byte)((b4 & 0x20) >> 5))); } } }
public roomHeader() { primaryPointer = ConstantsReader.GetAddress("room_header_pointer"); pointer_bank = ConstantsReader.GetAddress("room_header_pointers_bank"); roomHeaders = new i_roomHeader[numberOfHeaders]; readPointer(); }
public void addPotsItems() { int item_address_snes = (01 << 16) + (ROM.DATA[ConstantsReader.GetAddress("room_items_pointers") + (index * 2) + 1] << 8) + ROM.DATA[ConstantsReader.GetAddress("room_items_pointers") + (index * 2)]; int item_address = Addresses.snestopc(item_address_snes); while (true) { byte b1 = ROM.DATA[item_address]; byte b2 = ROM.DATA[item_address + 1]; byte b3 = ROM.DATA[item_address + 2]; //0x20 = bg2 if (b1 == 0xFF && b2 == 0xFF) { break; } int address = ((b2 & 0x1F) << 8 | b1) >> 1; int px = address % 64; int py = address >> 6; roomPotSave p = new roomPotSave(b3, (byte)((px)), (byte)((py)), (b2 & 0x20) == 0x20 ? true : false); pot_items.Add(p); //bit 7 is set if the object is a special object holes, switches //after 0x16 it goes to 0x80 item_address += 3; } }
public RoomSave(short roomId) { staircase_rooms = new byte[4]; staircase_plane = new byte[4]; blocks = new List <Room_Blocks>(); torches = new List <Room_Torches>(); doors = new List <DoorSave>(); chest_list = new List <ChestData>(); tilesObjects = new List <Room_Object>(); sprites = new List <Room_Sprite>(); pot_items = new List <roomPotSave>(); sortSprites = false; index = roomId; this.name = ROMStructure.roomsNames[index]; messageid = (short)((ROM.DATA[ConstantsReader.GetAddress("messages_id_dungeon") + (index * 2) + 1] << 8) + ROM.DATA[ConstantsReader.GetAddress("messages_id_dungeon") + (index * 2)]); loadHeader(); loadTilesObjects(); addSprites(); addBlocks(); addTorches(); addPotsItems(); isdamagePit(); }
internal indoor_damagepits() { POINTER_LOCATION = ConstantsReader.GetAddress("pit_pointer"); DATALENGTH_VALUE_LOCATION = ConstantsReader.GetAddress("pit_count"); dataAddress = PointerRead.LongRead_LoHiBank(POINTER_LOCATION); maxLength = Conversion.toUShort(ROM.DATA[DATALENGTH_VALUE_LOCATION + 1], ROM.DATA[DATALENGTH_VALUE_LOCATION + 0]) + embedded2; readData(); }
public byte music; //1byte //Will need to be renamed and changed to add support to MSU1 public Entrance(byte entranceId, bool startingEntrance = false) { room = (short)((ROM.DATA[(ConstantsReader.GetAddress("entrance_room") + (entranceId * 2)) + 1] << 8) + ROM.DATA[ConstantsReader.GetAddress("entrance_room") + (entranceId * 2)]); yposition = (short)(((ROM.DATA[(ConstantsReader.GetAddress("entrance_yposition") + (entranceId * 2)) + 1]) << 8) + ROM.DATA[ConstantsReader.GetAddress("entrance_yposition") + (entranceId * 2)]); xposition = (short)(((ROM.DATA[(ConstantsReader.GetAddress("entrance_xposition") + (entranceId * 2)) + 1]) << 8) + ROM.DATA[ConstantsReader.GetAddress("entrance_xposition") + (entranceId * 2)]); xscroll = (short)(((ROM.DATA[(ConstantsReader.GetAddress("entrance_xscroll") + (entranceId * 2)) + 1]) << 8) + ROM.DATA[ConstantsReader.GetAddress("entrance_xscroll") + (entranceId * 2)]); yscroll = (short)(((ROM.DATA[(ConstantsReader.GetAddress("entrance_yscroll") + (entranceId * 2)) + 1]) << 8) + ROM.DATA[ConstantsReader.GetAddress("entrance_yscroll") + (entranceId * 2)]); ycamera = (short)(((ROM.DATA[(ConstantsReader.GetAddress("entrance_camerayposition") + (entranceId * 2)) + 1]) << 8) + ROM.DATA[ConstantsReader.GetAddress("entrance_camerayposition") + (entranceId * 2)]); xcamera = (short)(((ROM.DATA[(ConstantsReader.GetAddress("entrance_cameraxposition") + (entranceId * 2)) + 1]) << 8) + ROM.DATA[ConstantsReader.GetAddress("entrance_cameraxposition") + (entranceId * 2)]); blockset = (byte)(ROM.DATA[(ConstantsReader.GetAddress("entrance_blockset") + entranceId)]); music = (byte)(ROM.DATA[(ConstantsReader.GetAddress("entrance_music") + entranceId)]); dungeon = (byte)(ROM.DATA[(ConstantsReader.GetAddress("entrance_dungeon") + entranceId)]); floor = (byte)(ROM.DATA[(ConstantsReader.GetAddress("entrance_floor") + entranceId)]); door = (byte)(ROM.DATA[(ConstantsReader.GetAddress("entrance_door") + entranceId)]); ladderbg = (byte)(ROM.DATA[(ConstantsReader.GetAddress("entrance_ladderbg") + entranceId)]); scrolling = (byte)(ROM.DATA[(ConstantsReader.GetAddress("entrance_scrolling") + entranceId)]); scrollquadrant = (byte)(ROM.DATA[(ConstantsReader.GetAddress("entrance_scrollquadrant") + entranceId)]); exit = (short)(((ROM.DATA[(ConstantsReader.GetAddress("entrance_exit") + (entranceId * 2)) + 1]) << 8) + ROM.DATA[ConstantsReader.GetAddress("entrance_exit") + (entranceId * 2)]); scrolledge_HU = (byte)(ROM.DATA[(ConstantsReader.GetAddress("entrance_scrolledge") + entranceId)]); scrolledge_FU = (byte)(ROM.DATA[(ConstantsReader.GetAddress("entrance_scrolledge") + entranceId) + 1]); scrolledge_HD = (byte)(ROM.DATA[(ConstantsReader.GetAddress("entrance_scrolledge") + entranceId) + 2]); scrolledge_FD = (byte)(ROM.DATA[(ConstantsReader.GetAddress("entrance_scrolledge") + entranceId) + 3]); scrolledge_HL = (byte)(ROM.DATA[(ConstantsReader.GetAddress("entrance_scrolledge") + entranceId) + 4]); scrolledge_FL = (byte)(ROM.DATA[(ConstantsReader.GetAddress("entrance_scrolledge") + entranceId) + 5]); scrolledge_HR = (byte)(ROM.DATA[(ConstantsReader.GetAddress("entrance_scrolledge") + entranceId) + 6]); scrolledge_FR = (byte)(ROM.DATA[(ConstantsReader.GetAddress("entrance_scrolledge") + entranceId) + 7]); if (startingEntrance == true) { room = (short)((ROM.DATA[(ConstantsReader.GetAddress("startingentrance_room") + ((entranceId) * 2)) + 1] << 8) + ROM.DATA[ConstantsReader.GetAddress("startingentrance_room") + ((entranceId) * 2)]); yposition = (short)(((ROM.DATA[(ConstantsReader.GetAddress("startingentrance_yposition") + ((entranceId) * 2)) + 1] & 0x01) << 8) + ROM.DATA[ConstantsReader.GetAddress("startingentrance_yposition") + ((entranceId) * 2)]); xposition = (short)(((ROM.DATA[(ConstantsReader.GetAddress("startingentrance_xposition") + ((entranceId) * 2)) + 1] & 0x01) << 8) + ROM.DATA[ConstantsReader.GetAddress("startingentrance_xposition") + ((entranceId) * 2)]); xscroll = (short)(((ROM.DATA[(ConstantsReader.GetAddress("startingentrance_xscroll") + ((entranceId) * 2)) + 1] & 0x01) << 8) + ROM.DATA[ConstantsReader.GetAddress("startingentrance_xscroll") + ((entranceId) * 2)]); yscroll = (short)(((ROM.DATA[(ConstantsReader.GetAddress("startingentrance_yscroll") + ((entranceId) * 2)) + 1] & 0x01) << 8) + ROM.DATA[ConstantsReader.GetAddress("startingentrance_yscroll") + ((entranceId) * 2)]); ycamera = (short)(((ROM.DATA[(ConstantsReader.GetAddress("startingentrance_camerayposition") + ((entranceId) * 2)) + 1] & 0x01) << 8) + ROM.DATA[ConstantsReader.GetAddress("startingentrance_camerayposition") + ((entranceId) * 2)]); xcamera = (short)(((ROM.DATA[(ConstantsReader.GetAddress("startingentrance_cameraxposition") + ((entranceId) * 2)) + 1] & 0x01) << 8) + ROM.DATA[ConstantsReader.GetAddress("startingentrance_cameraxposition") + ((entranceId) * 2)]); blockset = (byte)(ROM.DATA[(ConstantsReader.GetAddress("startingentrance_blockset") + entranceId)]); music = (byte)(ROM.DATA[(ConstantsReader.GetAddress("startingentrance_music") + entranceId)]); dungeon = (byte)(ROM.DATA[(ConstantsReader.GetAddress("startingentrance_dungeon") + entranceId)]); floor = (byte)(ROM.DATA[(ConstantsReader.GetAddress("startingentrance_floor") + entranceId)]); door = (byte)(ROM.DATA[(ConstantsReader.GetAddress("startingentrance_door") + entranceId)]); ladderbg = (byte)(ROM.DATA[(ConstantsReader.GetAddress("startingentrance_ladderbg") + entranceId)]); scrolling = (byte)(ROM.DATA[(ConstantsReader.GetAddress("startingentrance_scrolling") + entranceId)]); scrollquadrant = (byte)(ROM.DATA[(ConstantsReader.GetAddress("startingentrance_scrollquadrant") + entranceId)]); exit = (short)(((ROM.DATA[(ConstantsReader.GetAddress("startingentrance_exit") + (entranceId * 2)) + 1] & 0x01) << 8) + ROM.DATA[ConstantsReader.GetAddress("startingentrance_exit") + (entranceId * 2)]); scrolledge_HU = (byte)(ROM.DATA[(ConstantsReader.GetAddress("startingentrance_scrolledge") + entranceId)]); scrolledge_FU = (byte)(ROM.DATA[(ConstantsReader.GetAddress("startingentrance_scrolledge") + entranceId) + 1]); scrolledge_HD = (byte)(ROM.DATA[(ConstantsReader.GetAddress("startingentrance_scrolledge") + entranceId) + 2]); scrolledge_FD = (byte)(ROM.DATA[(ConstantsReader.GetAddress("startingentrance_scrolledge") + entranceId) + 3]); scrolledge_HL = (byte)(ROM.DATA[(ConstantsReader.GetAddress("startingentrance_scrolledge") + entranceId) + 4]); scrolledge_FL = (byte)(ROM.DATA[(ConstantsReader.GetAddress("startingentrance_scrolledge") + entranceId) + 5]); scrolledge_HR = (byte)(ROM.DATA[(ConstantsReader.GetAddress("startingentrance_scrolledge") + entranceId) + 6]); scrolledge_FR = (byte)(ROM.DATA[(ConstantsReader.GetAddress("startingentrance_scrolledge") + entranceId) + 7]); } }
public void Save32Tiles() { int index = 0; int c = tiles32count + 8; //Need to compare US and JP, JP Limit is 33C0, US is 33F0 for (int i = 0; i < c - 4; i += 6) { if (i >= 0x33F0) { Console.WriteLine("Too Many Unique Tiles !"); break; } //Top Left ROM.DATA[ConstantsReader.GetAddress("map32TilesTL") + (i + 0)] = (byte)(t32Unique[index + 0].tile0 & 0xFF); ROM.DATA[ConstantsReader.GetAddress("map32TilesTL") + (i + 1)] = (byte)(t32Unique[index + 1].tile0 & 0xFF); ROM.DATA[ConstantsReader.GetAddress("map32TilesTL") + (i + 2)] = (byte)(t32Unique[index + 2].tile0 & 0xFF); ROM.DATA[ConstantsReader.GetAddress("map32TilesTL") + (i + 3)] = (byte)(t32Unique[index + 3].tile0 & 0xFF); ROM.DATA[ConstantsReader.GetAddress("map32TilesTL") + (i + 4)] = (byte)(((t32Unique[index].tile0 >> 4) & 0xF0) + ((t32Unique[index + 1].tile0 >> 8) & 0x0F)); ROM.DATA[ConstantsReader.GetAddress("map32TilesTL") + (i + 5)] = (byte)(((t32Unique[index + 2].tile0 >> 4) & 0xF0) + ((t32Unique[index + 3].tile0 >> 8) & 0x0F)); //Top Right ROM.DATA[ConstantsReader.GetAddress("map32TilesTR") + (i)] = (byte)(t32Unique[index].tile1 & 0xFF); ROM.DATA[ConstantsReader.GetAddress("map32TilesTR") + (i + 1)] = (byte)(t32Unique[index + 1].tile1 & 0xFF); ROM.DATA[ConstantsReader.GetAddress("map32TilesTR") + (i + 2)] = (byte)(t32Unique[index + 2].tile1 & 0xFF); ROM.DATA[ConstantsReader.GetAddress("map32TilesTR") + (i + 3)] = (byte)(t32Unique[index + 3].tile1 & 0xFF); ROM.DATA[ConstantsReader.GetAddress("map32TilesTR") + (i + 4)] = (byte)(((t32Unique[index].tile1 >> 4) & 0xF0) | ((t32Unique[index + 1].tile1 >> 8) & 0x0F)); ROM.DATA[ConstantsReader.GetAddress("map32TilesTR") + (i + 5)] = (byte)(((t32Unique[index + 2].tile1 >> 4) & 0xF0) | ((t32Unique[index + 3].tile1 >> 8) & 0x0F)); //Bottom Left ROM.DATA[ConstantsReader.GetAddress("map32TilesBL") + (i)] = (byte)(t32Unique[index].tile2 & 0xFF); ROM.DATA[ConstantsReader.GetAddress("map32TilesBL") + (i + 1)] = (byte)(t32Unique[index + 1].tile2 & 0xFF); ROM.DATA[ConstantsReader.GetAddress("map32TilesBL") + (i + 2)] = (byte)(t32Unique[index + 2].tile2 & 0xFF); ROM.DATA[ConstantsReader.GetAddress("map32TilesBL") + (i + 3)] = (byte)(t32Unique[index + 3].tile2 & 0xFF); ROM.DATA[ConstantsReader.GetAddress("map32TilesBL") + (i + 4)] = (byte)(((t32Unique[index].tile2 >> 4) & 0xF0) | ((t32Unique[index + 1].tile2 >> 8) & 0x0F)); ROM.DATA[ConstantsReader.GetAddress("map32TilesBL") + (i + 5)] = (byte)(((t32Unique[index + 2].tile2 >> 4) & 0xF0) | ((t32Unique[index + 3].tile2 >> 8) & 0x0F)); //Bottom Right ROM.DATA[ConstantsReader.GetAddress("map32TilesBR") + (i)] = (byte)(t32Unique[index].tile3 & 0xFF); ROM.DATA[ConstantsReader.GetAddress("map32TilesBR") + (i + 1)] = (byte)(t32Unique[index + 1].tile3 & 0xFF); ROM.DATA[ConstantsReader.GetAddress("map32TilesBR") + (i + 2)] = (byte)(t32Unique[index + 2].tile3 & 0xFF); ROM.DATA[ConstantsReader.GetAddress("map32TilesBR") + (i + 3)] = (byte)(t32Unique[index + 3].tile3 & 0xFF); ROM.DATA[ConstantsReader.GetAddress("map32TilesBR") + (i + 4)] = (byte)(((t32Unique[index].tile3 >> 4) & 0xF0) | ((t32Unique[index + 1].tile3 >> 8) & 0x0F)); ROM.DATA[ConstantsReader.GetAddress("map32TilesBR") + (i + 5)] = (byte)(((t32Unique[index + 2].tile3 >> 4) & 0xF0) | ((t32Unique[index + 3].tile3 >> 8) & 0x0F)); index += 4; c += 2; } }
public void LoadDungeonsRooms() { int objCount = 0, chestCount = 0, itemCount = 0, blockCount = 0, torchCount = 0, pitsCount = 0, spritesCount = 0, roomCount = 0; for (int i = 0; i < 296; i++) { try { all_rooms[i] = new RoomSave((short)i); objCount += all_rooms[i].tilesObjects.Count; chestCount += all_rooms[i].chest_list.Count; itemCount += all_rooms[i].pot_items.Count; blockCount += all_rooms[i].blocks.Count; torchCount += all_rooms[i].torches.Count; pitsCount += all_rooms[i].damagepit ? 1 : 0; spritesCount += all_rooms[i].sprites.Count; if (all_rooms[i].tilesObjects.Count != 0) { roomCount++; } if (i == 5) { Console.WriteLine(all_rooms[i].tilesObjects.Count); } } catch (Exception e) { WriteLog("Error : " + e.Message.ToString(), Color.Red); return; } } LoadedProjectStatistics.blocksRooms = blockCount; LoadedProjectStatistics.chestsRooms = chestCount; LoadedProjectStatistics.chestsRoomsLength = ((ROM.DATA[ConstantsReader.GetAddress("chests_length_pointer") + 1] << 8) + (ROM.DATA[ConstantsReader.GetAddress("chests_length_pointer")])) / 3; LoadedProjectStatistics.blocksRoomsLength = ((short)((ROM.DATA[ConstantsReader.GetAddress("blocks_length") + 1] << 8) + ROM.DATA[ConstantsReader.GetAddress("blocks_length")])) / 4; LoadedProjectStatistics.torchesRoomsLength = 86;//(ROM.DATA[ConstantsReader.GetAddress("torches_length_pointer + 1] << 8) + ROM.DATA[ConstantsReader.GetAddress("torches_length_pointer]; LoadedProjectStatistics.entrancesRooms = 132; LoadedProjectStatistics.itemsRooms = itemCount; LoadedProjectStatistics.pitsRooms = pitsCount; LoadedProjectStatistics.pitsRoomsLength = (ROM.DATA[ConstantsReader.GetAddress("pit_count")] / 2); LoadedProjectStatistics.torchesRooms = torchCount; LoadedProjectStatistics.usedRooms = roomCount; LoadedProjectStatistics.spritesRooms = spritesCount; LoadedProjectStatistics.objectsRooms = objCount; WriteLog("All dungeon rooms data loaded properly : ", Color.Green); }
public void savemapstorom() { int pos = 0x1A0000; for (int i = 0; i < 160; i++) { int npos = 0; byte[] singlemap1 = new byte[256], singlemap2 = new byte[256]; for (int y = 0; y < 16; y++) { for (int x = 0; x < 16; x++) { singlemap1[npos] = (byte)(t32[npos + (i * 256)] & 0xFF); singlemap2[npos] = (byte)((t32[npos + (i * 256)] >> 8) & 0xFF); npos++; } } int snesPos = Addresses.pctosnes(pos); ROM.DATA[(ConstantsReader.GetAddress("compressedAllMap32PointersHigh")) + 0 + (int)(3 * i)] = (byte)(snesPos & 0xFF); ROM.DATA[(ConstantsReader.GetAddress("compressedAllMap32PointersHigh")) + 1 + (int)(3 * i)] = (byte)((snesPos >> 8) & 0xFF); ROM.DATA[(ConstantsReader.GetAddress("compressedAllMap32PointersHigh")) + 2 + (int)(3 * i)] = (byte)((snesPos >> 16) & 0xFF); ROM.DATA[pos] = 0xE0; ROM.DATA[pos + 1] = 0xFF; pos += 2; for (int j = 0; j < 256; j++) { ROM.DATA[pos] = singlemap2[j]; pos += 1; } ROM.DATA[pos] = 0xFF; pos += 1; snesPos = Addresses.pctosnes(pos); ROM.DATA[(ConstantsReader.GetAddress("compressedAllMap32PointersLow")) + 0 + (int)(3 * i)] = (byte)((snesPos >> 00) & 0xFF); ROM.DATA[(ConstantsReader.GetAddress("compressedAllMap32PointersLow")) + 1 + (int)(3 * i)] = (byte)((snesPos >> 08) & 0xFF); ROM.DATA[(ConstantsReader.GetAddress("compressedAllMap32PointersLow")) + 2 + (int)(3 * i)] = (byte)((snesPos >> 16) & 0xFF); ROM.DATA[pos] = 0xE0; ROM.DATA[pos + 1] = 0xFF; pos += 2; for (int j = 0; j < 256; j++) { ROM.DATA[pos] = singlemap1[j]; pos += 1; } ROM.DATA[pos] = 0xFF; pos += 1; } Save32Tiles(); }
public void addTorches() { int bytes_count = (ROM.DATA[ConstantsReader.GetAddress("torches_length_pointer") + 1] << 8) + ROM.DATA[ConstantsReader.GetAddress("torches_length_pointer")]; for (int i = 0; i < bytes_count; i += 2) { byte b1 = ROM.DATA[ConstantsReader.GetAddress("torch_data") + i]; byte b2 = ROM.DATA[ConstantsReader.GetAddress("torch_data") + i + 1]; if (b1 == 0xFF && b2 == 0xFF) { continue; } if (((b2 << 8) + b1) == index) // if roomindex = indexread { i += 2; while (true) { b1 = ROM.DATA[ConstantsReader.GetAddress("torch_data") + i]; b2 = ROM.DATA[ConstantsReader.GetAddress("torch_data") + i + 1]; if (b1 == 0xFF && b2 == 0xFF) { break; } int address = ((b2 & 0x1F) << 8 | b1) >> 1; int px = address % 64; int py = address >> 6; torches.Add(new Room_Torches(0x150, (byte)px, (byte)py, 0, (byte)((b2 & 0x20) >> 5))); //tilesObjects[tilesObjects.Count - 1].is_torch = true; i += 2; } } else { while (true) { b1 = ROM.DATA[ConstantsReader.GetAddress("torch_data") + i]; b2 = ROM.DATA[ConstantsReader.GetAddress("torch_data") + i + 1]; if (b1 == 0xFF && b2 == 0xFF) { break; } i += 2; } } } }
public void addSprites() { int spritePointer = (04 << 16) + (ROM.DATA[ConstantsReader.GetAddress("rooms_sprite_pointer") + 1] << 8) + (ROM.DATA[ConstantsReader.GetAddress("rooms_sprite_pointer")]); //09 bank ? Need to check if HM change that int sprite_address_snes = (09 << 16) + (ROM.DATA[spritePointer + (index * 2) + 1] << 8) + ROM.DATA[spritePointer + (index * 2)]; int sprite_address = Addresses.snestopc(sprite_address_snes); sortSprites = ROM.DATA[sprite_address] == 1 ? true : false; sprite_address += 1; while (true) { byte b1 = ROM.DATA[sprite_address], b2 = ROM.DATA[sprite_address + 1], b3 = ROM.DATA[sprite_address + 2]; if (b1 == 0xFF) { break; } Room_Sprite s = new Room_Sprite(b3, (byte)(b2 & 0x1F), (byte)(b1 & 0x1F), Sprites_Names.name[b3], (byte)((b2 & 0xE0) >> 5), (byte)((b1 & 0x60) >> 5), (byte)((b1 & 0x80) >> 7), 0); sprites.Add(s); if (sprites.Count > 1) { Room_Sprite spr = sprites[sprites.Count - 1]; Room_Sprite prevSprite = sprites[sprites.Count - 2]; if (spr.id == 0xE4 && spr.x == 0x00 && spr.y == 0x1E && spr.layer == 1 && ((spr.subtype << 3) + spr.overlord) == 0x18) { if (prevSprite != null) { prevSprite.keyDrop = 1; sprites.RemoveAt(sprites.Count - 1); } } if (spr.id == 0xE4 && spr.x == 0x00 && spr.y == 0x1D && spr.layer == 1 && ((spr.subtype << 3) + spr.overlord) == 0x18) { if (prevSprite != null) { prevSprite.keyDrop = 2; sprites.RemoveAt(sprites.Count - 1); } } } sprite_address += 3; } }
public void isdamagePit() { int pitCount = (ROM.DATA[ConstantsReader.GetAddress("pit_count")] / 2); int pitPointer = (ROM.DATA[ConstantsReader.GetAddress("pit_pointer") + 2] << 16) + (ROM.DATA[ConstantsReader.GetAddress("pit_pointer") + 1] << 8) + (ROM.DATA[ConstantsReader.GetAddress("pit_pointer")]); pitPointer = Addresses.snestopc(pitPointer); for (int i = 0; i < pitCount; i++) { if (((ROM.DATA[pitPointer + 1 + (i * 2)] << 8) + (ROM.DATA[pitPointer + (i * 2)])) == index) { damagepit = true; return; } } }
public void writeOverworldSpriteset(string path) { if (!Directory.Exists(path + "Overworld")) { Directory.CreateDirectory(path + "Overworld"); } const int dim = 143 * 4; byte[] owblocksetgroups = new byte[dim]; for (int i = 0; i < dim; i++) { owblocksetgroups[i] = ROM.DATA[ConstantsReader.GetAddress("sprite_blockset_pointer") + i]; } File.WriteAllText(path + "Overworld//SpritesetGroups.json", JsonConvert.SerializeObject(owblocksetgroups)); }
public void LoadOverworldEntrances() { for (int i = 0; i < 129; i++) { all_entrancesOW[i] = JsonConvert.DeserializeObject <EntranceOW>(File.ReadAllText("ProjectDirectory//Overworld//Entrances//Entrance" + i.ToString("D3") + ".json")); ROM.DATA[ConstantsReader.GetAddress("OWEntranceMap") + (i * 2) + 1] = (byte)((all_entrancesOW[i].mapId >> 8) & 0xFF); ROM.DATA[ConstantsReader.GetAddress("OWEntranceMap") + (i * 2)] = (byte)((all_entrancesOW[i].mapId) & 0xFF); ROM.DATA[ConstantsReader.GetAddress("OWEntrancePos") + (i * 2) + 1] = (byte)((all_entrancesOW[i].mapPos >> 8) & 0xFF); ROM.DATA[ConstantsReader.GetAddress("OWEntrancePos") + (i * 2)] = (byte)((all_entrancesOW[i].mapPos) & 0xFF); ROM.DATA[ConstantsReader.GetAddress("OWEntranceEntranceId") + i] = (byte)((all_entrancesOW[i].entranceId) & 0xFF); } WriteLog("Overworld Entrances data loaded properly", Color.Green); }
public void writeOverworldEntrances(string path) { if (!Directory.Exists(path + "Overworld")) { Directory.CreateDirectory(path + "Overworld"); } if (!Directory.Exists(path + "Overworld//Entrances")) { Directory.CreateDirectory(path + "Overworld//Entrances"); } for (int i = 0; i < 129; i++) { short mapId = (short)((ROM.DATA[ConstantsReader.GetAddress("OWEntranceMap") + (i * 2) + 1] << 8) + (ROM.DATA[ConstantsReader.GetAddress("OWEntranceMap") + (i * 2)])); short mapPos = (short)((ROM.DATA[ConstantsReader.GetAddress("OWEntrancePos") + (i * 2) + 1] << 8) + (ROM.DATA[ConstantsReader.GetAddress("OWEntrancePos") + (i * 2)])); byte entranceId = (byte)((ROM.DATA[ConstantsReader.GetAddress("OWEntranceEntranceId") + i])); EntranceOW eo = new EntranceOW(mapId, mapPos, entranceId); File.WriteAllText(path + "Overworld//Entrances//Entrance" + i.ToString("D3") + ".json", JsonConvert.SerializeObject(eo)); } }
/// <summary> /// Initilializes a new instance of indoor_sprites /// </summary> internal indoor_sprites() { primaryPointer = ConstantsReader.GetAddress("rooms_sprite_pointer"); switch (RegionId.myRegion) { case (int)RegionId.Region.Japan: case (int)RegionId.Region.USA: codePointer = 0x4C296; break; case (int)RegionId.Region.German: codePointer = 0x4C2BE; break; default: throw new NotImplementedException(); } updatePointers(); }
public void loadHeader() { //address of the room header int headerPointer = (ROM.DATA[ConstantsReader.GetAddress("room_header_pointer") + 2] << 16) + (ROM.DATA[ConstantsReader.GetAddress("room_header_pointer") + 1] << 8) + (ROM.DATA[ConstantsReader.GetAddress("room_header_pointer")]); headerPointer = Addresses.snestopc(headerPointer); int address = (ROM.DATA[ConstantsReader.GetAddress("room_header_pointers_bank")] << 16) + (ROM.DATA[(headerPointer + 1) + (index * 2)] << 8) + ROM.DATA[(headerPointer) + (index * 2)]; header_location = Addresses.snestopc(address); bg2 = (byte)((ROM.DATA[header_location] >> 5) & 0x07); collision = (byte)((ROM.DATA[header_location] >> 2) & 0x07); light = (((ROM.DATA[header_location]) & 0x01) == 1 ? true : false); if (light) { bg2 = 00; } palette = (byte)((ROM.DATA[header_location + 1] & 0x3F)); blockset = (byte)((ROM.DATA[header_location + 2])); spriteset = (byte)((ROM.DATA[header_location + 3])); effect = (byte)((ROM.DATA[header_location + 4])); tag1 = (byte)((ROM.DATA[header_location + 5])); tag2 = (byte)((ROM.DATA[header_location + 6])); holewarp_plane = (byte)((ROM.DATA[header_location + 7]) & 0x03); staircase_plane[0] = (byte)((ROM.DATA[header_location + 7] >> 2) & 0x03); staircase_plane[1] = (byte)((ROM.DATA[header_location + 7] >> 4) & 0x03); staircase_plane[2] = (byte)((ROM.DATA[header_location + 7] >> 6) & 0x03); staircase_plane[3] = (byte)((ROM.DATA[header_location + 8]) & 0x03); holewarp = (byte)((ROM.DATA[header_location + 9])); staircase_rooms[0] = (byte)((ROM.DATA[header_location + 10])); staircase_rooms[1] = (byte)((ROM.DATA[header_location + 11])); staircase_rooms[2] = (byte)((ROM.DATA[header_location + 12])); staircase_rooms[3] = (byte)((ROM.DATA[header_location + 13])); }
public void loadChests(ref List <ChestData> chests_in_room) { int cpos = (ROM.DATA[ConstantsReader.GetAddress("chests_data_pointer1") + 2] << 16) + (ROM.DATA[ConstantsReader.GetAddress("chests_data_pointer1") + 1] << 8) + (ROM.DATA[ConstantsReader.GetAddress("chests_data_pointer1")]); cpos = Addresses.snestopc(cpos); int clength = (ROM.DATA[ConstantsReader.GetAddress("chests_length_pointer") + 1] << 8) + (ROM.DATA[ConstantsReader.GetAddress("chests_length_pointer")]); for (int i = 0; i < (clength); i++) { if ((((ROM.DATA[cpos + (i * 3) + 1] << 8) + (ROM.DATA[cpos + (i * 3)])) & 0x7FFF) == index) { //there's a chest in that room ! bool big = false; if ((((ROM.DATA[cpos + (i * 3) + 1] << 8) + (ROM.DATA[cpos + (i * 3)])) & 0x8000) == 0x8000) //????? { big = true; } chests_in_room.Add(new ChestData(ROM.DATA[cpos + (i * 3) + 2], big)); // } } }
public indoor_chests() : base(3) { primaryPointer_location = new int[] { ConstantsReader.GetAddress("chests_data_pointer1"), ConstantsReader.GetAddress("chests_data_pointer2"), ConstantsReader.GetAddress("chests_data_pointer3"), }; addressOfTotalMax = ConstantsReader.GetAddress("chests_length_pointer"); byte[] b = ROM.Read(addressOfTotalMax, 2); totalMax = Conversion.toUShort(b[1], b[0]); if (totalMax % numberOfPointers != 0) { throw new Exception(); } refreshPointer3Bytes(); readAllChests(); }
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); } } } } }
public void AssembleMap16Tiles(bool fromJson = false) { if (!fromJson) { int tpos = ConstantsReader.GetAddress("map16Tiles"); for (int i = 0; i < 3760; i += 1) { Tile8 t0 = new Tile8(BitConverter.ToInt16(ROM.DATA, (tpos))); tpos += 2; Tile8 t1 = new Tile8(BitConverter.ToInt16(ROM.DATA, (tpos))); tpos += 2; Tile8 t2 = new Tile8(BitConverter.ToInt16(ROM.DATA, (tpos))); tpos += 2; Tile8 t3 = new Tile8(BitConverter.ToInt16(ROM.DATA, (tpos))); tpos += 2; tiles16.Add(new Tile16(t0, t1, t2, t3)); } } else { tiles16 = JsonConvert.DeserializeObject <Tile16[]>(File.ReadAllText("ProjectDirectory//Overworld//Tiles16.json")).ToList(); } }
public static byte[] DecompressTiles() //to gfx.bin { int gfxPointer1 = Addresses.snestopc((ROM.DATA[ConstantsReader.GetAddress("gfx_1_pointer") + 1] << 8) + (ROM.DATA[ConstantsReader.GetAddress("gfx_1_pointer")])), gfxPointer2 = Addresses.snestopc((ROM.DATA[ConstantsReader.GetAddress("gfx_2_pointer") + 1] << 8) + (ROM.DATA[ConstantsReader.GetAddress("gfx_2_pointer")])), gfxPointer3 = Addresses.snestopc((ROM.DATA[ConstantsReader.GetAddress("gfx_3_pointer") + 1] << 8) + (ROM.DATA[ConstantsReader.GetAddress("gfx_3_pointer")])); byte[] buffer = new byte[0x6F800], // (185) bufferBlock; int bufferPos = 0; for (int i = 0; i < 96; i++) { byte[] b = new byte[] { ROM.DATA[gfxPointer3 + i], ROM.DATA[gfxPointer2 + i], ROM.DATA[gfxPointer1 + i], 0 }; int addr = BitConverter.ToInt32(b, 0); addresses[i] = Addresses.snestopc(addr); //Console.WriteLine(Addresses.snestopc(addr).ToString("X6")); byte[] tbufferBlock = Decompress.ALTTPDecompressGraphics(ROM.DATA, Addresses.snestopc(addr), 0x800, ref blockSize[i]); bufferBlock = tbufferBlock; if (tbufferBlock.Length != 0x600) { bpp[i] = 2; bufferBlock = new byte[0x600]; for (int j = 0; j < 0x600; j++) { bufferBlock[j] = tbufferBlock[j]; } } else { bpp[i] = 3; } //bufferBlock = Decompress(Addresses.snestopc(addr), ROM.DATA); for (int j = 0; j < bufferBlock.Length; j++) { buffer[bufferPos] = bufferBlock[j]; bufferPos++; } } for (int i = 96; i < 223; i++) { bpp[i] = 3; if (i < 115 || i > 126) //not compressed { byte[] b = new byte[] { ROM.DATA[gfxPointer3 + i], ROM.DATA[gfxPointer2 + i], ROM.DATA[gfxPointer1 + i], 0 }; int addr = BitConverter.ToInt32(b, 0); addresses[i] = Addresses.snestopc(addr); byte[] tbufferBlock = Decompress.ALTTPDecompressGraphics(ROM.DATA, Addresses.snestopc(addr), 0x800, ref blockSize[i]); bufferBlock = tbufferBlock; if (tbufferBlock.Length != 0x600) { bpp[i] = 2; bufferBlock = new byte[0xC00]; //Console.WriteLine(tbufferBlock.Length); for (int j = 0; j < tbufferBlock.Length; j++) { bufferBlock[j] = tbufferBlock[j]; } //Console.WriteLine("Buffer Size :" + tbufferBlock.Length.ToString("X4")); } for (int j = 0; j < bufferBlock.Length; j++) { buffer[bufferPos] = bufferBlock[j]; bufferPos++; } } else { byte[] b = new byte[] { ROM.DATA[gfxPointer3 + i], ROM.DATA[gfxPointer2 + i], ROM.DATA[gfxPointer1 + i], 0 }; int addr = BitConverter.ToInt32(b, 0); addr = Addresses.snestopc(addr); bpp[i] = 3; for (int j = 0; j < 0x600; j++) { buffer[bufferPos] = ROM.DATA[addr + j]; bufferPos++; } } } /*FileStream fs = new FileStream("testgfx.gfx", FileMode.OpenOrCreate, FileAccess.Write); * fs.Write(buffer.ToArray(), 0, buffer.Length); * fs.Close();*/ return(buffer); }
public OverworldConfig() { hardCodedDWGrass = GFX.getColor((short)((ROM.DATA[ConstantsReader.GetAddress("hardcodedGrassDW") + 1] << 8) + ROM.DATA[ConstantsReader.GetAddress("hardcodedGrassDW")])); hardCodedLWGrass = GFX.getColor((short)((ROM.DATA[ConstantsReader.GetAddress("hardcodedGrassLW") + 1] << 8) + ROM.DATA[ConstantsReader.GetAddress("hardcodedGrassLW")])); hardCodedDMGrass = GFX.getColor((short)((ROM.DATA[ConstantsReader.GetAddress("hardcodedGrassSpecial") + 1] << 8) + ROM.DATA[ConstantsReader.GetAddress("hardcodedGrassSpecial")])); }
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.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++; } } }
public void loadTilesObjects(bool floor = true) { //adddress of the room objects int objectPointer = (ROM.DATA[ConstantsReader.GetAddress("room_object_pointer") + 2] << 16) + (ROM.DATA[ConstantsReader.GetAddress("room_object_pointer") + 1] << 8) + (ROM.DATA[ConstantsReader.GetAddress("room_object_pointer")]); objectPointer = Addresses.snestopc(objectPointer); int room_address = objectPointer + (index * 3); int tile_address = (ROM.DATA[room_address + 2] << 16) + (ROM.DATA[room_address + 1] << 8) + ROM.DATA[room_address]; int objects_location = Addresses.snestopc(tile_address); if (floor) { floor1 = (byte)(ROM.DATA[objects_location] & 0x0F); floor2 = (byte)((ROM.DATA[objects_location] >> 4) & 0x0F); } layout = (byte)((ROM.DATA[objects_location + 1] >> 2) & 0x07); List <ChestData> chests_in_room = new List <ChestData>(); loadChests(ref chests_in_room); int pos = objects_location + 2; byte b1 = 0; byte b2 = 0; byte b3 = 0; byte posX = 0; byte posY = 0; byte sizeX = 0; byte sizeY = 0; byte sizeXY = 0; short oid = 0; int layer = 0; bool door = false; bool endRead = false; while (endRead == false) { b1 = ROM.DATA[pos]; b2 = ROM.DATA[pos + 1]; if (b1 == 0xFF && b2 == 0xFF) { pos += 2; //we jump to layer2 layer++; door = false; if (layer == 3) { endRead = true; break; } continue; } if (b1 == 0xF0 && b2 == 0xFF) { pos += 2; //we jump to layer2 door = true; continue; } b3 = ROM.DATA[pos + 2]; if (door) { pos += 2; } else { pos += 3; } if (door == false) { if (b3 >= 0xF8) { oid = (short)((b3 << 4) | 0x80 + (((b2 & 0x03) << 2) + ((b1 & 0x03)))); posX = (byte)((b1 & 0xFC) >> 2); posY = (byte)((b2 & 0xFC) >> 2); sizeXY = (byte)((((b1 & 0x03) << 2) + (b2 & 0x03))); } else //subtype1 { oid = b3; posX = (byte)((b1 & 0xFC) >> 2); posY = (byte)((b2 & 0xFC) >> 2); sizeX = (byte)((b1 & 0x03)); sizeY = (byte)((b2 & 0x03)); sizeXY = (byte)(((sizeX << 2) + sizeY)); } if (b1 >= 0xFC) //subtype2 (not scalable? ) { oid = (short)((b3 & 0x3F) + 0x100); posX = (byte)(((b2 & 0xF0) >> 4) + ((b1 & 0x3) << 4)); posY = (byte)(((b2 & 0x0F) << 2) + ((b3 & 0xC0) >> 6)); sizeXY = 0; } tilesObjects.Add(new Room_Object(oid, posX, posY, sizeXY, (byte)layer)); //IF Object is a chest loaded and there's object in the list chest if (oid == 0xF99) { if (chests_in_room.Count > 0) { chest_list.Add(new ChestData(chests_in_room[0].itemIn, false)); chests_in_room.RemoveAt(0); } } else if (oid == 0xFB1) { if (chests_in_room.Count > 0) { chest_list.Add(new ChestData(chests_in_room[0].itemIn, true)); chests_in_room.RemoveAt(0); } } } else { doors.Add(new DoorSave((short)((b2 << 8) + b1))); continue; } } }