try:
    from fast_enum import FastEnum
except ImportError:
    from enum import IntFlag as FastEnum

from RoomData import DoorKind, Position
from source.dungeon.RoomObject import DoorObject, RoomObject


class Room:

    def __init__(self, layout, layer1, layer2, doors, layer3=None):
        self.layout = layout
        self.layer1 = layer1
        self.layer2 = layer2
        self.layer3 = layer3
        self.doors = doors

    def write_to_rom(self, address, rom):
        offset = 0
        rom.write_bytes(address, self.layout)
        offset += 2
        for obj in self.layer1:
            rom.write_bytes(address + offset, obj.data)
            offset += 3
        rom.write_bytes(address + offset, [0xFF, 0xFF])
        offset += 2
        for obj in self.layer2:
            rom.write_bytes(address + offset, obj.data)
            offset += 3
        rom.write_bytes(address + offset, [0xFF, 0xFF])
        offset += 2
        if self.layer3:
            for obj in self.layer3:
                rom.write_bytes(address + offset, obj.data)
                offset += 3
        rom.write_bytes(address + offset, [0xF0, 0xFF])
        offset += 2
        door_start = offset
        for door in self.doors:
            rom.write_bytes(address + offset, door.get_bytes())
            offset += 2
        rom.write_bytes(address + offset, [0xFF, 0xFF])
        return door_start, offset + 2  # how many bytes were written

    def find_all_pots(self):
        pots = []
        pots.extend([x for x in self.layer1 if x.data[2] in {0xFA, 0xFB} and not x.dummy])
        pots.extend([x for x in self.layer2 if x.data[2] in {0xFA, 0xFB} and not x.dummy])
        if self.layer3:
           pots.extend([x for x in self.layer3 if x.data[2] in {0xFA, 0xFB} and not x.dummy])
        return pots



Room0006 = Room([0xE1, 0x00],
                [RoomObject(0x1FA15C, [0x1B, 0xA3, 0xC8]),
                 RoomObject(0x1FA15F, [0x58, 0xA3, 0xC8]),
                 RoomObject(0x1FA162, [0x1B, 0xD8, 0xC8]),
                 RoomObject(0x1FA165, [0x58, 0xD8, 0xC8]),
                 RoomObject(0x1FA168, [0x17, 0x9F, 0x3F]),
                 RoomObject(0x1FA16B, [0x54, 0x9F, 0x3F]),
                 RoomObject(0x1FA16E, [0x17, 0xA3, 0x79]),
                 RoomObject(0x1FA171, [0x14, 0xE1, 0x79]),
                 RoomObject(0x1FA174, [0x17, 0xEB, 0x40]),
                 RoomObject(0x1FA177, [0x54, 0xEB, 0x40]),
                 RoomObject(0x1FA17A, [0x6B, 0xA3, 0x7A]),
                 RoomObject(0x1FA17D, [0x68, 0xE1, 0x7A]),
                 RoomObject(0x1FA180, [0x21, 0x90, 0xF8]),
                 RoomObject(0x1FA183, [0x51, 0x90, 0xF8]),
                 RoomObject(0x1FA186, [0x0C, 0xA5, 0x7F]),
                 RoomObject(0x1FA189, [0x6C, 0xA5, 0x80])],
                [], [DoorObject(Position.SouthW, DoorKind.Trap)])


Room0007 = Room([0x81, 0x1C],
                [RoomObject(0x1FCAF0, [0x0A, 0x4E, 0x0D]),
                 RoomObject(0x1FCAF3, [0x0A, 0xAA, 0x0E]),
                 RoomObject(0x1FCAF6, [0x0B, 0x51, 0x61]),
                 RoomObject(0x1FCAF9, [0xC0, 0x2C, 0xA2]),
                 RoomObject(0x1FCAFC, [0xB0, 0x20, 0x0F]),
                 RoomObject(0x1FCAFF, [0xB0, 0x22, 0x62]),
                 RoomObject(0x1FCB02, [0xFE, 0xC1, 0x02]),
                 RoomObject(0x1FCB05, [0xC9, 0x38, 0x01]),
                 RoomObject(0x1FCB08, [0xFF, 0xA3, 0x82]),
                 RoomObject(0x1FCB0B, [0xBA, 0xE6, 0x10]),
                 RoomObject(0x1FCB0E, [0xE8, 0xAA, 0x62]),
                 RoomObject(0x1FCB11, [0xFF, 0x43, 0xB9]),
                 RoomObject(0x1FCB14, [0x53, 0x53, 0xE0]),
                 RoomObject(0x1FCB17, [0x91, 0x53, 0xE0]),
                 RoomObject(0x1FCB1A, [0x53, 0x91, 0xE0]),
                 RoomObject(0x1FCB1D, [0x91, 0x91, 0xE0]),
                 RoomObject(0x1FCB20, [0x3C, 0x6B, 0xC2]),
                 RoomObject(0x1FCB23, [0x3D, 0x9B, 0xC3]),
                 RoomObject(0x1FCB26, [0x54, 0xA6, 0xC3]),
                 RoomObject(0x1FCB29, [0x5C, 0xAA, 0xC3]),
                 RoomObject(0x1FCB2C, [0x68, 0xB1, 0xC3]),
                 RoomObject(0x1FCB2F, [0x75, 0xB0, 0xC3]),
                 RoomObject(0x1FCB32, [0x8F, 0xB1, 0xC3]),
                 RoomObject(0x1FCB35, [0x9B, 0xAA, 0xC3]),
                 RoomObject(0x1FCB38, [0xA6, 0xA0, 0xC3]),
                 RoomObject(0x1FCB3B, [0xAD, 0x98, 0xC3]),
                 RoomObject(0x1FCB3E, [0xB4, 0x6A, 0xC2]),
                 RoomObject(0x1FCB41, [0x51, 0x3D, 0xC3]),
                 RoomObject(0x1FCB44, [0x45, 0x49, 0xC3]),
                 RoomObject(0x1FCB47, [0x3D, 0x51, 0xC3]),
                 RoomObject(0x1FCB4A, [0x9C, 0x39, 0xC2]),
                 RoomObject(0x1FCB4D, [0xA1, 0x49, 0xC3]),
                 RoomObject(0x1FCB50, [0xAD, 0x51, 0xC3]),
                 RoomObject(0x1FCB53, [0x3A, 0x50, 0x8A]),
                 RoomObject(0x1FCB56, [0x38, 0x50, 0x22]),
                 RoomObject(0x1FCB59, [0x44, 0x44, 0x69]),
                 RoomObject(0x1FCB5C, [0x44, 0x44, 0x22]),
                 RoomObject(0x1FCB5F, [0x58, 0x13, 0x05]),
                 RoomObject(0x1FCB62, [0x60, 0x15, 0x55]),
                 RoomObject(0x1FCB65, [0x78, 0x10, 0x3A]),
                 RoomObject(0x1FCB68, [0x08, 0x5B, 0x65]),
                 RoomObject(0x1FCB6B, [0x0C, 0x61, 0x7F]),
                 RoomObject(0x1FCB6E, [0xC8, 0x39, 0x05]),
                 RoomObject(0x1FCB71, [0xE8, 0x5B, 0x66]),
                 RoomObject(0x1FCB74, [0xEC, 0x4A, 0x80]),
                 RoomObject(0x1FCB77, [0x58, 0xEB, 0x06]),
                 RoomObject(0x1FCB7A, [0x60, 0xED, 0x56]),
                 RoomObject(0x1FCB7D, [0x78, 0xEC, 0x3B]),
                 RoomObject(0x1FCB80, [0x50, 0x38, 0x69]),
                 RoomObject(0x1FCB83, [0x50, 0x38, 0x5F]),
                 RoomObject(0x1FCB86, [0xA8, 0x38, 0x69]),
                 RoomObject(0x1FCB89, [0xA8, 0x44, 0x22]),
                 RoomObject(0x1FCB8C, [0xB4, 0x44, 0x69]),
                 RoomObject(0x1FCB8F, [0xB4, 0x51, 0x22]),
                 RoomObject(0x1FCB92, [0xC6, 0x50, 0x8A]),
                 RoomObject(0x1FCB95, [0x3B, 0xC8, 0x22]),
                 RoomObject(0x1FCB98, [0x8B, 0xC8, 0x22]),
                 RoomObject(0x1FCB9B, [0x74, 0xBC, 0x69]),
                 RoomObject(0x1FCB9E, [0x88, 0xBC, 0x69]),
                 RoomObject(0x1FCBA1, [0x63, 0x3C, 0xC2]),
                 RoomObject(0x1FCBA4, [0x66, 0x4F, 0x29]),
                 RoomObject(0x1FCBA7, [0x64, 0x50, 0x6B]),
                 RoomObject(0x1FCBAA, [0x5C, 0x54, 0x2B]),
                 RoomObject(0x1FCBAD, [0x5C, 0x58, 0x6B]),
                 RoomObject(0x1FCBB0, [0x54, 0x5C, 0x2B]),
                 RoomObject(0x1FCBB3, [0x54, 0x60, 0x6B]),
                 RoomObject(0x1FCBB6, [0x4C, 0x64, 0x2B]),
                 RoomObject(0x1FCBB9, [0x4E, 0x6B, 0x6B]),
                 RoomObject(0x1FCBBC, [0x4C, 0x98, 0x2D]),
                 RoomObject(0x1FCBBF, [0x54, 0x9C, 0x6B]),
                 RoomObject(0x1FCBC2, [0x54, 0xA0, 0x2D]),
                 RoomObject(0x1FCBC5, [0x5C, 0xA4, 0x6B]),
                 RoomObject(0x1FCBC8, [0x5C, 0xA8, 0x2D]),
                 RoomObject(0x1FCBCB, [0x64, 0xAC, 0x6B]),
                 RoomObject(0x1FCBCE, [0x66, 0xB3, 0x2A]),
                 RoomObject(0x1FCBD1, [0x98, 0xAC, 0x6A]),
                 RoomObject(0x1FCBD4, [0x98, 0xA8, 0x2E]),
                 RoomObject(0x1FCBD7, [0xA0, 0xA4, 0x6A]),
                 RoomObject(0x1FCBDA, [0xA0, 0xA0, 0x2E]),
                 RoomObject(0x1FCBDD, [0xA8, 0x9C, 0x6A]),
                 RoomObject(0x1FCBE0, [0xA8, 0x98, 0x2E]),
                 RoomObject(0x1FCBE3, [0xB2, 0x6B, 0x6A]),
                 RoomObject(0x1FCBE6, [0xA8, 0x64, 0x2C]),
                 RoomObject(0x1FCBE9, [0xA8, 0x60, 0x6A]),
                 RoomObject(0x1FCBEC, [0xA0, 0x5C, 0x2C]),
                 RoomObject(0x1FCBEF, [0xA0, 0x58, 0x6A]),
                 RoomObject(0x1FCBF2, [0x98, 0x54, 0x2C]),
                 RoomObject(0x1FCBF5, [0x98, 0x50, 0x6A]),
                 RoomObject(0x1FCBF8, [0x68, 0x74, 0xC2]),
                 RoomObject(0x1FCBFB, [0x68, 0x71, 0x27]),
                 RoomObject(0x1FCBFE, [0x68, 0x77, 0x6A]),
                 RoomObject(0x1FCC01, [0x74, 0x77, 0x6B]),
                 RoomObject(0x1FCC04, [0x68, 0x85, 0x28]),
                 RoomObject(0x1FCC07, [0xFC, 0x31, 0x72]),
                 RoomObject(0x1FCC0A, [0x74, 0xAE, 0x04]),
                 RoomObject(0x1FCC0D, [0x71, 0xA0, 0xE0]),
                 RoomObject(0x1FCC10, [0x0A, 0x13, 0xA0]),
                 RoomObject(0x1FCC13, [0x0A, 0xBF, 0xA1]),
                 RoomObject(0x1FCC16, [0xBE, 0xF7, 0xA3]),
                 RoomObject(0x1FCC19, [0xC3, 0x11, 0xC0]),
                 RoomObject(0x1FCC1C, [0xD1, 0x31, 0x00])],
                [], [])

Room001C = Room([0xE1, 0x00],
                [RoomObject(0x1FF74B, [0x2D, 0x32, 0xA4]),
                 RoomObject(0x1FF74E, [0xA9, 0x1E, 0xDC]),
                 RoomObject(0x1FF751, [0xA8, 0x91, 0x3A]),
                 RoomObject(0x1FF754, [0x88, 0xAD, 0x76]),
                 RoomObject(0x1FF757, [0xEC, 0xAD, 0x77]),
                 RoomObject(0x1FF75A, [0xA8, 0x50, 0x3D]),
                 RoomObject(0x1FF75D, [0xD0, 0x50, 0x3D]),
                 RoomObject(0x1FF760, [0x30, 0xA9, 0x3D]),
                 RoomObject(0x1FF763, [0x30, 0xC1, 0x3D]),
                 RoomObject(0x1FF766, [0xFC, 0x69, 0x38]),
                 RoomObject(0x1FF769, [0x97, 0x9F, 0xD1]),
                 RoomObject(0x1FF76C, [0xCD, 0x9F, 0xD1]),
                 RoomObject(0x1FF76F, [0x97, 0xDC, 0xD1]),
                 RoomObject(0x1FF772, [0xCD, 0xDC, 0xD1]),
                 RoomObject(0x1FF775, [0xBD, 0x32, 0xF9]),
                 RoomObject(0x1FF778, [0xB1, 0x22, 0xF9]),
                 RoomObject(0x1FF77B, [0xC9, 0x22, 0xF9]),], [],
                [DoorObject(Position.InteriorE, DoorKind.TrapTriggerable),
                 DoorObject(Position.InteriorS, DoorKind.Trap), DoorObject(Position.InteriorW, DoorKind.Dashable)])


Room0029 = Room([0xE5, 0x00],
                [RoomObject(0x1FC188, [0x97, 0x9C, 0xDE]),
                 RoomObject(0x1FC18B, [0xB7, 0x9C, 0xDE]),
                 RoomObject(0x1FC18E, [0xD6, 0x9C, 0xDE]),
                 RoomObject(0x1FC191, [0x97, 0xE4, 0xDE]),
                 RoomObject(0x1FC194, [0xB7, 0xE4, 0xDE]),
                 RoomObject(0x1FC197, [0xD6, 0xE4, 0xDE]),
                 RoomObject(0x1FC19A, [0x94, 0xA7, 0xDE]),
                 RoomObject(0x1FC19D, [0x94, 0xC7, 0xDE]),
                 RoomObject(0x1FC1A0, [0xE4, 0xA7, 0xDE]),
                 RoomObject(0x1FC1A3, [0xE4, 0xC7, 0xDE])],
                [RoomObject(0x1FC1A8, [0x03, 0x03, 0xCA]),
                 RoomObject(0x1FC1AB, [0x43, 0x03, 0xCA]),
                 RoomObject(0x1FC1AE, [0x83, 0x03, 0xCA]),
                 RoomObject(0x1FC1B1, [0xC3, 0x03, 0xCA]),
                 RoomObject(0x1FC1B4, [0x03, 0x43, 0xCA]),
                 RoomObject(0x1FC1B7, [0x43, 0x43, 0xCA]),
                 RoomObject(0x1FC1BA, [0x83, 0x43, 0xCA]),
                 RoomObject(0x1FC1BD, [0xC3, 0x43, 0xCA]),
                 RoomObject(0x1FC1C0, [0x03, 0x83, 0xCA]),
                 RoomObject(0x1FC1C3, [0x43, 0x83, 0xCA]),
                 RoomObject(0x1FC1C6, [0x83, 0x83, 0xCA]),
                 RoomObject(0x1FC1C9, [0xC3, 0x83, 0xCA]),
                 RoomObject(0x1FC1CC, [0x03, 0xC3, 0xCA]),
                 RoomObject(0x1FC1CF, [0x43, 0xC3, 0xCA]),
                 RoomObject(0x1FC1D2, [0x83, 0xC3, 0xCA]),
                 RoomObject(0x1FC1D5, [0xC3, 0xC3, 0xCA])],
                [], layer3=[RoomObject(0x1FC1DA, [0x9F, 0xA7, 0xC6]),
                            RoomObject(0x1FC1DD, [0xD4, 0xA7, 0xC6]),
                            RoomObject(0x1FC1E0, [0xFE, 0xF9, 0xF4]),
                            RoomObject(0x1FC1E3, [0xFF, 0x1E, 0x74]),
                            RoomObject(0x1FC1E6, [0xFE, 0x5C, 0x74]),
                            RoomObject(0x1FC1E9, [0xFF, 0x9C, 0x74])])


Room0033 = Room([0xE9, 0x00], [], [], [DoorObject(Position.SouthW, DoorKind.Trap)])


Room004D = Room([0x82, 0x1C],
                [RoomObject(0x1FFD43, [0x09, 0x34, 0x0D]),
                 RoomObject(0x1FFD46, [0x08, 0x3A, 0x61]),
                 RoomObject(0x1FFD49, [0x09, 0xC0, 0x0E]),
                 RoomObject(0x1FFD4C, [0x08, 0xC2, 0x61]),
                 RoomObject(0x1FFD4F, [0xD1, 0x10, 0x0F]),
                 RoomObject(0x1FFD52, [0xE8, 0x3A, 0x62]),
                 RoomObject(0x1FFD55, [0x5E, 0x1C, 0x03]),
                 RoomObject(0x1FFD58, [0x17, 0x49, 0x63]),
                 RoomObject(0x1FFD5B, [0xDF, 0x4B, 0x64]),
                 RoomObject(0x1FFD5E, [0xDC, 0xCA, 0x64]),
                 RoomObject(0x1FFD61, [0xFF, 0x7D, 0xCB]),
                 RoomObject(0x1FFD64, [0x9D, 0xDF, 0x04]),
                 RoomObject(0x1FFD67, [0x3B, 0x5B, 0xE0]),
                 RoomObject(0x1FFD6A, [0x7B, 0x5B, 0xE0]),
                 RoomObject(0x1FFD6D, [0xB8, 0x5B, 0xE0]),
                 RoomObject(0x1FFD70, [0x6A, 0xB1, 0xE0]),
                 RoomObject(0x1FFD73, [0x78, 0x54, 0xC2]),
                 RoomObject(0x1FFD76, [0x5B, 0x2A, 0xC2]),
                 RoomObject(0x1FFD79, [0x98, 0x2A, 0xC2]),
                 RoomObject(0x1FFD7C, [0x21, 0x4B, 0xC3]),
                 RoomObject(0x1FFD7F, [0x21, 0x7B, 0xC3]),
                 RoomObject(0x1FFD82, [0x21, 0xA1, 0xC3]),
                 RoomObject(0x1FFD85, [0x38, 0x7B, 0xC2]),
                 RoomObject(0x1FFD88, [0x48, 0x8A, 0xC2]),
                 RoomObject(0x1FFD8B, [0x3A, 0xAA, 0xC2]),
                 RoomObject(0x1FFD8E, [0x5B, 0x9C, 0xC2]),
                 RoomObject(0x1FFD91, [0xC9, 0x4B, 0xC3]),
                 RoomObject(0x1FFD94, [0xC9, 0x7B, 0xC3]),
                 RoomObject(0x1FFD97, [0xB8, 0x79, 0xC2]),
                 RoomObject(0x1FFD9A, [0xA8, 0x88, 0xC2]),
                 RoomObject(0x1FFD9D, [0x9B, 0x9B, 0xC2]),
                 RoomObject(0x1FFDA0, [0x9B, 0xD0, 0xC2]),
                 RoomObject(0x1FFDA3, [0xD0, 0xA3, 0xC2]),
                 RoomObject(0x1FFDA6, [0x78, 0x8C, 0xC2]),
                 RoomObject(0x1FFDA9, [0x15, 0x45, 0x22]),
                 RoomObject(0x1FFDAC, [0x59, 0x1F, 0x69]),
                 RoomObject(0x1FFDAF, [0xA5, 0x1F, 0x69]),
                 RoomObject(0x1FFDB2, [0xC9, 0x45, 0x22]),
                 RoomObject(0x1FFDB5, [0x68, 0xE4, 0x5E]),
                 RoomObject(0x1FFDB8, [0x15, 0xB9, 0x22]),
                 RoomObject(0x1FFDBB, [0x35, 0xB9, 0x69]),
                 RoomObject(0x1FFDBE, [0x37, 0xD9, 0x22]),
                 RoomObject(0x1FFDC1, [0x88, 0xD9, 0x22]),
                 RoomObject(0x1FFDC4, [0x98, 0xD9, 0x69]),
                 RoomObject(0x1FFDC7, [0x66, 0xCB, 0x2A]),
                 RoomObject(0x1FFDCA, [0x69, 0xC9, 0x04]),
                 RoomObject(0x1FFDCD, [0x79, 0xCB, 0xF9]),
                 RoomObject(0x1FFDD0, [0x8D, 0xBA, 0xF9]),
                 RoomObject(0x1FFDD3, [0x37, 0x57, 0x29]),
                 RoomObject(0x1FFDD6, [0x87, 0x57, 0x29]),
                 RoomObject(0x1FFDD9, [0x78, 0x5A, 0x6A]),
                 RoomObject(0x1FFDDC, [0x84, 0x5A, 0x6B]),
                 RoomObject(0x1FFDDF, [0x78, 0x65, 0x28]),
                 RoomObject(0x1FFDE2, [0x35, 0x5B, 0x6B]),
                 RoomObject(0x1FFDE5, [0x34, 0x7A, 0x2D]),
                 RoomObject(0x1FFDE8, [0x44, 0x7E, 0x6B]),
                 RoomObject(0x1FFDEB, [0x44, 0x8A, 0x2D]),
                 RoomObject(0x1FFDEE, [0x54, 0x8E, 0x6B]),
                 RoomObject(0x1FFDF1, [0x55, 0x9B, 0x2A]),
                 RoomObject(0x1FFDF4, [0x78, 0x8E, 0x6A]),
                 RoomObject(0x1FFDF7, [0x78, 0x89, 0x27]),
                 RoomObject(0x1FFDFA, [0x84, 0x8E, 0x6B]),
                 RoomObject(0x1FFDFD, [0x85, 0x9B, 0x2A]),
                 RoomObject(0x1FFE00, [0xA8, 0x8E, 0x6A]),
                 RoomObject(0x1FFE03, [0xA8, 0x8A, 0x2E]),
                 RoomObject(0x1FFE06, [0xB8, 0x7E, 0x6A]),
                 RoomObject(0x1FFE09, [0xB8, 0x7A, 0x2E]),
                 RoomObject(0x1FFE0C, [0xC9, 0x5B, 0x6A]),
                 RoomObject(0x1FFE0F, [0x66, 0xAF, 0x29]),
                 RoomObject(0x1FFE12, [0x65, 0xB1, 0x6B]),
                 RoomObject(0x1FFE15, [0x99, 0xB1, 0x6A]),
                 RoomObject(0x1FFE18, [0x38, 0x4B, 0x03]),
                 RoomObject(0x1FFE1B, [0xA8, 0x4B, 0x03]),
                 RoomObject(0x1FFE1E, [0x48, 0x13, 0x3A]),
                 RoomObject(0x1FFE21, [0x0C, 0x4A, 0x7F]),
                 RoomObject(0x1FFE24, [0xEC, 0x4A, 0x80]),
                 RoomObject(0x1FFE27, [0xFE, 0xE1, 0x39]),
                 RoomObject(0x1FFE2A, [0x09, 0x11, 0xA0]),
                 RoomObject(0x1FFE2D, [0xD5, 0x11, 0xA2]),
                 RoomObject(0x1FFE30, [0x09, 0xD5, 0xA1])],
                [RoomObject(0x1FFE35, [0x5B, 0x19, 0xDB]),
                 RoomObject(0x1FFE38, [0x98, 0x19, 0xDB]),
                 RoomObject(0x1FFE3B, [0x11, 0x4B, 0xDB]),
                 RoomObject(0x1FFE3E, [0x11, 0x8A, 0xDB]),
                 RoomObject(0x1FFE41, [0x39, 0x48, 0xDB]),
                 RoomObject(0x1FFE44, [0xA9, 0x48, 0xDB]),
                 RoomObject(0x1FFE47, [0xD9, 0x4B, 0xDB]),
                 RoomObject(0x1FFE4A, [0xD9, 0x8B, 0xDB]),
                 RoomObject(0x1FFE4D, [0x6A, 0xC8, 0xDB]),
                 RoomObject(0x1FFE50, [0x9B, 0xCA, 0xDB]),
                 RoomObject(0x1FFE53, [0xD9, 0xCA, 0xDB])],
                [DoorObject(Position.NorthW, DoorKind.SmallKey),  DoorObject(Position.WestS, DoorKind.Normal)])

Room005A = Room([0xE9, 0x00],
                [RoomObject(0x1FA7CD, [0xA8, 0xA8, 0xDE]),
                 RoomObject(0x1FA7D0, [0xB0, 0xA0, 0xDE]),
                 RoomObject(0x1FA7D3, [0xB8, 0xA8, 0xDE]),
                 RoomObject(0x1FA7D6, [0xC0, 0xA0, 0xDE]),
                 RoomObject(0x1FA7D9, [0xC8, 0xA8, 0xDE]),
                 RoomObject(0x1FA7DC, [0xD0, 0xA0, 0xDE])],
                [], [DoorObject(Position.SouthE, DoorKind.Trap)])

Room006C = Room([0xE2, 0x00],
                [RoomObject(0x1FFA58, [0x17, 0x9F, 0xE8]),
                 RoomObject(0x1FFA5B, [0x4D, 0x9F, 0xE8]),
                 RoomObject(0x1FFA5E, [0x17, 0xDC, 0xE8]),
                 RoomObject(0x1FFA61, [0x4D, 0xDC, 0xE8]),
                 RoomObject(0x1FFA64, [0x18, 0xE1, 0xFE]),
                 RoomObject(0x1FFA67, [0x88, 0xAD, 0x76]),
                 RoomObject(0x1FFA6A, [0x99, 0xBC, 0x33]),
                 RoomObject(0x1FFA6D, [0x9B, 0xBB, 0x34]),
                 RoomObject(0x1FFA70, [0x9B, 0xCF, 0x34]),
                 RoomObject(0x1FFA73, [0xD8, 0xB8, 0x34]),
                 RoomObject(0x1FFA76, [0xD8, 0xCC, 0x34]),
                 RoomObject(0x1FFA79, [0xAF, 0xAA, 0xFE]),
                 RoomObject(0x1FFA7C, [0xC7, 0xAA, 0xFE]),
                 RoomObject(0x1FFA7F, [0xAF, 0xD2, 0xFE]),
                 RoomObject(0x1FFA82, [0xC7, 0xD2, 0xFE]),
                 RoomObject(0x1FFA85, [0x28, 0x11, 0x3A]),
                 RoomObject(0x1FFA88, [0x28, 0x91, 0x3A]),
                 RoomObject(0x1FFA8B, [0xFC, 0xE1, 0x38]),
                 RoomObject(0x1FFA8E, [0x2B, 0x33, 0xFA]),
                 RoomObject(0x1FFA91, [0x53, 0x33, 0xFA]),
                 RoomObject(0x1FFA94, [0x2B, 0x53, 0xFA]),
                 RoomObject(0x1FFA97, [0x53, 0x53, 0xFA])], [],
                [DoorObject(Position.InteriorS, DoorKind.Trap2), DoorObject(Position.InteriorW, DoorKind.Trap),
                 DoorObject(Position.EastS, DoorKind.Normal)])

Room0090 = Room([0xE1, 0x00],
                [RoomObject(0x1FBAA0, [0x28, 0xEC, 0x56]),
                 RoomObject(0x1FBAA3, [0x48, 0xEC, 0x56]),
                 RoomObject(0x1FBAA6, [0x1B, 0xA2, 0xFF])],
                [RoomObject(0x1FBAAB, [0x16, 0x9C, 0xFE])], [DoorObject(Position.SouthW, DoorKind.Trap)])

Room00A4 = Room([0xE1, 0x00],
                [RoomObject(0x1FE702, [0xFC, 0x08, 0x00]),
                 RoomObject(0x1FE705, [0x13, 0x80, 0x01]),
                 RoomObject(0x1FE708, [0xFD, 0xC8, 0x02]),
                 RoomObject(0x1FE70B, [0x02, 0x93, 0x61]),
                 RoomObject(0x1FE70E, [0xFC, 0x0E, 0x81]),
                 RoomObject(0x1FE711, [0x13, 0xE8, 0x02]),
                 RoomObject(0x1FE714, [0xFD, 0xCE, 0x83]),
                 RoomObject(0x1FE717, [0x72, 0x93, 0x62]),
                 RoomObject(0x1FE71A, [0x13, 0x93, 0xC4]),
                 RoomObject(0x1FE71D, [0x51, 0x93, 0xC4]),
                 RoomObject(0x1FE720, [0x51, 0xC9, 0xC4]),
                 RoomObject(0x1FE723, [0x10, 0xC9, 0xC4]),
                 RoomObject(0x1FE726, [0x0E, 0x8D, 0xDE]),
                 RoomObject(0x1FE729, [0x0D, 0x9C, 0xDE]),
                 RoomObject(0x1FE72C, [0x0C, 0xA5, 0xDE]),
                 RoomObject(0x1FE72F, [0x5E, 0x8C, 0xDE]),
                 RoomObject(0x1FE732, [0x65, 0x94, 0xDE]),
                 RoomObject(0x1FE735, [0x6C, 0x9C, 0xDE])],
                [RoomObject(0x1FE73A, [0x2E, 0x98, 0xFF])], [DoorObject(Position.SouthW, DoorKind.Trap)])

Room00AC = Room([0xE9, 0x00],
                [RoomObject(0x1FD9B1, [0x88, 0xA4, 0x0D]),
                 RoomObject(0x1FD9B4, [0x88, 0xD0, 0x0E]),
                 RoomObject(0x1FD9B7, [0xE0, 0x90, 0x0F]),
                 RoomObject(0x1FD9BA, [0xE0, 0xE4, 0x10]),
                 RoomObject(0x1FD9BD, [0x89, 0xAB, 0x61]),
                 RoomObject(0x1FD9C0, [0xE9, 0xAB, 0x62]),
                 RoomObject(0x1FD9C3, [0x88, 0x91, 0xA0]),
                 RoomObject(0x1FD9C6, [0x88, 0xE5, 0xA1]),
                 RoomObject(0x1FD9C9, [0xE4, 0x91, 0xA2]),
                 RoomObject(0x1FD9CC, [0xE4, 0xF5, 0xA3])],
                [RoomObject(0x1FD9D1, [0xB1, 0xA8, 0xFF])], [DoorObject(Position.SouthE, DoorKind.Trap)])

Room00C8 = Room([0xE1, 0x00],
                [RoomObject(0x0A9587, [0x98, 0x92, 0x3A]),
                 RoomObject(0x0A958A, [0x88, 0xAA, 0x65]),
                 RoomObject(0x0A958D, [0xE8, 0xAA, 0x66])], [], [DoorObject(Position.SouthE, DoorKind.Trap)])

Room00DE = Room([0xE4, 0x00], [], [RoomObject(0x1FCAE5, [0xAD, 0x21, 0xF9])], [])

Room010C = Room([0xE0, 0x08],
                [RoomObject(0x03F25D, [0xFC, 0x62, 0x00]),
                 RoomObject(0x03F260, [0x19, 0x33, 0x61]),
                 RoomObject(0x03F263, [0xFC, 0x66, 0x81]),
                 RoomObject(0x03F266, [0x29, 0x22, 0x01]),
                 RoomObject(0x03F269, [0xFD, 0x62, 0x02]),
                 RoomObject(0x03F26C, [0x59, 0x33, 0x62]),
                 RoomObject(0x03F26F, [0xFD, 0x66, 0x83]),
                 RoomObject(0x03F272, [0xFC, 0x89, 0x00]),
                 RoomObject(0x03F275, [0x22, 0xA1, 0x61]),
                 RoomObject(0x03F278, [0xFC, 0x8E, 0x81]),
                 RoomObject(0x03F27B, [0x90, 0xCA, 0x0E]),
                 RoomObject(0x03F27E, [0xD0, 0xE6, 0x10]),
                 RoomObject(0x03F281, [0xFE, 0x41, 0x00]),
                 RoomObject(0x03F284, [0x93, 0x23, 0x61]),
                 RoomObject(0x03F287, [0x92, 0x98, 0x61]),
                 RoomObject(0x03F28A, [0xFF, 0x81, 0x02]),
                 RoomObject(0x03F28D, [0xE3, 0x23, 0x62]),
                 RoomObject(0x03F290, [0xE2, 0x98, 0x62]),
                 RoomObject(0x03F293, [0xFE, 0x71, 0xC8]),
                 RoomObject(0x03F296, [0xAD, 0x1C, 0x03]),
                 RoomObject(0x03F299, [0xFF, 0x51, 0xCA]),
                 RoomObject(0x03F29C, [0x9D, 0x2D, 0x63]),
                 RoomObject(0x03F29F, [0xFE, 0x75, 0x89]),
                 RoomObject(0x03F2A2, [0xAD, 0x58, 0x04]),
                 RoomObject(0x03F2A5, [0xD5, 0x2D, 0x64]),
                 RoomObject(0x03F2A8, [0xFF, 0x55, 0x8B]),
                 RoomObject(0x03F2AB, [0xFE, 0x78, 0x08]),
                 RoomObject(0x03F2AE, [0xAD, 0x80, 0x03]),
                 RoomObject(0x03F2B1, [0xFF, 0x58, 0x0A]),
                 RoomObject(0x03F2B4, [0x9C, 0x91, 0x63]),
                 RoomObject(0x03F2B7, [0xFE, 0x7A, 0x09]),
                 RoomObject(0x03F2BA, [0xAD, 0xA0, 0x04]),
                 RoomObject(0x03F2BD, [0xFF, 0x5A, 0x0B]),
                 RoomObject(0x03F2C0, [0xD4, 0x91, 0x64]),
                 RoomObject(0x03F2C3, [0x2C, 0x2E, 0xDC]),
                 RoomObject(0x03F2C6, [0x3D, 0x3E, 0xF9]),
                 RoomObject(0x03F2C9, [0x32, 0xA9, 0xF9]),
                 RoomObject(0x03F2CC, [0x3A, 0xA9, 0xF9]),
                 RoomObject(0x03F2CF, [0x42, 0xA9, 0xF9]),
                 RoomObject(0x03F2D2, [0x4A, 0xA9, 0xF9]),
                 RoomObject(0x03F2D5, [0x57, 0x9E, 0x69]),
                 RoomObject(0x03F2D8, [0x54, 0xDC, 0x69]),
                 RoomObject(0x03F2DB, [0x38, 0xC8, 0x89]),
                 RoomObject(0x03F2DE, [0x58, 0x9C, 0x89]),
                 RoomObject(0x03F2E1, [0x58, 0xA8, 0x89]),
                 RoomObject(0x03F2E4, [0x58, 0xB4, 0x89]),
                 RoomObject(0x03F2E7, [0x58, 0xC0, 0x89]),
                 RoomObject(0x03F2EA, [0x58, 0xCC, 0x89]),
                 RoomObject(0x03F2ED, [0x58, 0xD8, 0x89]),
                 RoomObject(0x03F2F0, [0x58, 0xE4, 0x89]),
                 RoomObject(0x03F2F3, [0xAA, 0x2E, 0xC8]),
                 RoomObject(0x03F2F6, [0xAA, 0x29, 0x3F]),
                 RoomObject(0x03F2F9, [0xAA, 0x2E, 0x79]),
                 RoomObject(0x03F2FC, [0xAA, 0x59, 0x40]),
                 RoomObject(0x03F2FF, [0xD6, 0x2E, 0x7A]),
                 RoomObject(0x03F302, [0xAA, 0x90, 0xC8]),
                 RoomObject(0x03F305, [0xAA, 0x8D, 0x3F]),
                 RoomObject(0x03F308, [0xA8, 0x93, 0x79]),
                 RoomObject(0x03F30B, [0xAA, 0xA1, 0x40]),
                 RoomObject(0x03F30E, [0xD4, 0x93, 0x7A]),
                 RoomObject(0x03F311, [0xB9, 0x5B, 0xF9]),
                 RoomObject(0x03F314, [0xB9, 0xA3, 0xF9]),
                 RoomObject(0x03F317, [0x9C, 0x68, 0x22]),
                 RoomObject(0x03F31A, [0x9C, 0x6A, 0x69]),
                 RoomObject(0x03F31D, [0x9C, 0x7C, 0x22]),
                 RoomObject(0x03F320, [0xD4, 0x7C, 0x22]),
                 RoomObject(0x03F323, [0x9C, 0xB0, 0x22]),
                 RoomObject(0x03F326, [0xD4, 0xB0, 0x22]),
                 RoomObject(0x03F329, [0xB3, 0x73, 0xFA]),
                 RoomObject(0x03F32C, [0xCD, 0x68, 0xDD]),
                 RoomObject(0x03F32F, [0xB8, 0xC0, 0xDD]),
                 RoomObject(0x03F332, [0x08, 0x00, 0x60]),
                 RoomObject(0x03F335, [0x10, 0x00, 0x60]),
                 RoomObject(0x03F338, [0x1B, 0x10, 0xC0]),
                 RoomObject(0x03F33B, [0x59, 0x10, 0xC0]),
                 RoomObject(0x03F33E, [0x68, 0x23, 0xC0]),
                 RoomObject(0x03F341, [0x68, 0x61, 0xC0]),
                 RoomObject(0x03F344, [0x1B, 0x91, 0x60]),
                 RoomObject(0x03F347, [0x88, 0x10, 0x60]),
                 RoomObject(0x03F34A, [0xF0, 0x10, 0x60]),
                 RoomObject(0x03F34D, [0x90, 0xDF, 0xA1]),
                 RoomObject(0x03F350, [0xD4, 0xF7, 0xA3])], [],
                [DoorObject(Position.InteriorW, DoorKind.TrapTriggerable),
                 DoorObject(Position.SouthW, DoorKind.CaveEntrance), DoorObject(Position.SouthE, DoorKind.CaveEntrance)]
                )

Room0127 = Room([0xE1, 0x00],
                [RoomObject(0x0AB600, [0xFE, 0x89, 0x00]),
                 RoomObject(0x0AB603, [0xA2, 0xA1, 0x61]),
                 RoomObject(0x0AB606, [0xFE, 0x8E, 0x81]),
                 RoomObject(0x0AB609, [0xFF, 0x49, 0x02]),
                 RoomObject(0x0AB60C, [0xD2, 0xA1, 0x62]),
                 RoomObject(0x0AB60F, [0xFF, 0x4E, 0x83]),
                 RoomObject(0x0AB612, [0x20, 0xB3, 0xDD]),
                 RoomObject(0x0AB615, [0x50, 0xB3, 0xDD]),
                 RoomObject(0x0AB618, [0x33, 0xCB, 0xFA]),
                 RoomObject(0x0AB61B, [0x3B, 0xCB, 0xFA]),
                 RoomObject(0x0AB61E, [0x43, 0xCB, 0xFA]),
                 RoomObject(0x0AB621, [0x4B, 0xCB, 0xFA]),
                 RoomObject(0x0AB624, [0xBF, 0x94, 0xF9]),
                 RoomObject(0x0AB627, [0xB3, 0xB3, 0xFA], True),
                 RoomObject(0x0AB62A, [0xCB, 0xB3, 0xFA], True),
                 RoomObject(0x0AB62D, [0xAD, 0xC8, 0xDF]),
                 RoomObject(0x0AB630, [0xC4, 0xC8, 0xDF]),
                 RoomObject(0x0AB633, [0xB3, 0xE3, 0xFA], True),
                 RoomObject(0x0AB636, [0xCB, 0xE3, 0xFA], True),
                 RoomObject(0x0AB639, [0x81, 0x93, 0xC0]),
                 RoomObject(0x0AB63C, [0x81, 0xD2, 0xC0]),
                 RoomObject(0x0AB63F, [0xE1, 0x93, 0xC0]),
                 RoomObject(0x0AB642, [0xE1, 0xD2, 0xC0])],
                [], [DoorObject(Position.SouthW, DoorKind.CaveEntrance),
                     DoorObject(Position.SouthE, DoorKind.CaveEntrance)])

# boss room id, room data, shell x, shell y, clear layer 2
boss_rooms = {
    'Eastern Palace': (0xc8, Room00C8, 0x2B, 0x28, False),
    'Desert Palace': (0x33, Room0033, 0x0B, 0x28, False),
    'Tower of Hera': (7, Room0007, 0x18, 0x16, False),
    'Palace of Darkness': (0x5A, Room005A, 0x2B, 0x28, False),
    'Swamp Palace': (6, Room0006, 0x0B, 0x28, False),
    'Skull Woods': (0x29, Room0029, 0x2B, 0x28, False),
    'Thieves Town': (0xac, Room00AC, 0x2B, 0x28, True),
    'Ice Palace': (0xde, Room00DE, 0x2B, 0x08, True),
    'Misery Mire': (0x90, Room0090, 0x0B, 0x28, True),
    'Turtle Rock': (0xa4, Room00A4, 0x0B, 0x28, True),
}

gt_boss_room = {
    'bottom': (0x1C, Room001C, 0x2B, 0x28, False),
    'middle': (0x6C, Room006C, 0x0B, 0x28, False),
    'top': (0x4D, Room004D, 0x18, 0x16, False),
}
