コード例 #1
0
ファイル: test_address.py プロジェクト: amorri40/awake
 def testFromVirtualAndCurrent(self):
     current1 = address.fromPhysical(0x4000)
     current4 = address.fromPhysical(0x10000)
     self.assertEquals(str(address.fromVirtualAndCurrent(0x0000, current1)), "0000:0000")
     self.assertEquals(str(address.fromVirtualAndCurrent(0x0000, current4)), "0000:0000")
     self.assertEquals(str(address.fromVirtualAndCurrent(0x4000, current1)), "0001:4000")
     self.assertEquals(str(address.fromVirtualAndCurrent(0x4000, current4)), "0004:4000")
     self.assertEquals(str(address.fromVirtualAndCurrent(0x7FFF, current1)), "0001:7FFF")
     self.assertEquals(str(address.fromVirtualAndCurrent(0x7FFF, current4)), "0004:7FFF")
     self.assertEquals(str(address.fromVirtualAndCurrent(0x8000, current1)), "VRAM:8000")
     self.assertEquals(str(address.fromVirtualAndCurrent(0xFFFF, current4)), "IO:FFFF")
コード例 #2
0
 def testFromVirtualAndCurrent(self):
     current1 = address.fromPhysical(0x4000)
     current4 = address.fromPhysical(0x10000)
     self.assertEquals(str(address.fromVirtualAndCurrent(0x0000, current1)),
                       "0000:0000")
     self.assertEquals(str(address.fromVirtualAndCurrent(0x0000, current4)),
                       "0000:0000")
     self.assertEquals(str(address.fromVirtualAndCurrent(0x4000, current1)),
                       "0001:4000")
     self.assertEquals(str(address.fromVirtualAndCurrent(0x4000, current4)),
                       "0004:4000")
     self.assertEquals(str(address.fromVirtualAndCurrent(0x7FFF, current1)),
                       "0001:7FFF")
     self.assertEquals(str(address.fromVirtualAndCurrent(0x7FFF, current4)),
                       "0004:7FFF")
     self.assertEquals(str(address.fromVirtualAndCurrent(0x8000, current1)),
                       "VRAM:8000")
     self.assertEquals(str(address.fromVirtualAndCurrent(0xFFFF, current4)),
                       "IO:FFFF")
コード例 #3
0
ファイル: graph.py プロジェクト: resonancellc/awake
def produce_map(proj, ownership):

    granularity = 4
    romsize = 512 * 1024
    width = 64
    height = romsize / granularity / width

    img = Image.new('RGB', (width, height))

    for i in range(romsize / granularity):
        owners = set()
        for j in range(i * granularity, (i + 1) * granularity):
            addr = address.fromPhysical(j)
            owners |= ownership[addr]

        color = (0, 0, 0)
        addr = address.fromPhysical(i * granularity)
        if len(owners) == 1:
            color = (0, 255, 0)
        elif len(owners) >= 2:
            color = (255, 0, 0)
        elif addr.bank() in (0x08, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12,
                             0x13, 0x1C, 0x1D):
            color = (0, 0, 255)
        elif addr.bank() == 0x16 and addr.virtual() >= 0x5700:
            color = (0, 0, 255)
        elif addr.bank() == 0x09 and addr.virtual() >= 0x6700:
            color = (0, 0, 255)
        elif proj.rom.get(addr) == 0xFF:
            color = (0, 0, 127)

        x = i % width
        y = i / width
        img.putpixel((x, y), color)

    img.save('ownership.png')
    print('image saved')
コード例 #4
0
ファイル: graph.py プロジェクト: amorri40/awake
def produce_map(proj, ownership):

    granularity = 4
    romsize = 512*1024
    width = 64
    height = romsize/granularity/width

    img = Image.new('RGB', (width, height))

    for i in range(romsize/granularity):
        owners = set()
        for j in range(i*granularity, (i+1)*granularity):
            addr = address.fromPhysical(j)
            owners |= ownership[addr]

        color = (0, 0, 0)
        addr = address.fromPhysical(i*granularity)
        if len(owners) == 1:
            color = (0, 255, 0)
        elif len(owners) >= 2:
            color = (255, 0, 0)
        elif addr.bank() in (0x08, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x1C, 0x1D):
            color = (0, 0, 255)
        elif addr.bank() == 0x16 and addr.virtual() >= 0x5700:
            color = (0, 0, 255)
        elif addr.bank() == 0x09 and addr.virtual() >= 0x6700:
            color = (0, 0, 255)
        elif proj.rom.get(addr) == 0xFF:
            color = (0, 0, 127)

        x = i % width
        y = i / width
        img.putpixel((x, y), color)

    img.save('ownership.png')
    print('image saved')
コード例 #5
0
    def testOffset(self):
        zero = address.fromVirtual(0)
        self.assertEquals(str(zero.offset(0)), "0000:0000")
        self.assertEquals(str(zero.offset(0x3FFF)), "0000:3FFF")
        self.assertEquals(str(zero.offset(0x4000)), "(A):4000")
        self.assertEquals(str(zero.offset(0x8000)), "VRAM:8000")

        first = address.fromPhysical(0x4000)
        self.assertEquals(str(first.offset(-0x4000)), "0000:0000")
        self.assertEquals(str(first.offset(0)), "0001:4000")
        self.assertEquals(str(first.offset(0x3FFF)), "0001:7FFF")
        self.assertEquals(str(first.offset(0x4000)), "VRAM:8000")

        high = address.fromVirtual(0x8000)
        self.assertEquals(str(high.offset(-0x8000)), "0000:0000")
        self.assertEquals(str(high.offset(-0x1000)), "(A):7000")
        self.assertEquals(str(high.offset(0)), "VRAM:8000")
        self.assertEquals(str(high.offset(0x0FFF)), "VRAM:8FFF")
コード例 #6
0
ファイル: test_address.py プロジェクト: amorri40/awake
    def testOffset(self):
        zero = address.fromVirtual(0)
        self.assertEquals(str(zero.offset(0)), "0000:0000")
        self.assertEquals(str(zero.offset(0x3FFF)), "0000:3FFF")
        self.assertEquals(str(zero.offset(0x4000)), "(A):4000")
        self.assertEquals(str(zero.offset(0x8000)), "VRAM:8000")

        first = address.fromPhysical(0x4000)
        self.assertEquals(str(first.offset(-0x4000)), "0000:0000")
        self.assertEquals(str(first.offset(0)), "0001:4000")
        self.assertEquals(str(first.offset(0x3FFF)), "0001:7FFF")
        self.assertEquals(str(first.offset(0x4000)), "VRAM:8000")

        high = address.fromVirtual(0x8000)
        self.assertEquals(str(high.offset(-0x8000)), "0000:0000")
        self.assertEquals(str(high.offset(-0x1000)), "(A):7000")
        self.assertEquals(str(high.offset(0)), "VRAM:8000")
        self.assertEquals(str(high.offset(0x0FFF)), "VRAM:8FFF")
コード例 #7
0
ファイル: database.py プロジェクト: Jenna1337/awake
    def produce_map(self, proj):

        romsize = 512 * 1024
        width = 256
        height = romsize / width

        import Image
        img = Image.new('RGB', (width, height))

        for i in range(512 * 1024):
            addr = address.fromPhysical(i)
            if addr.bank() in (0x08, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12,
                               0x13, 0x1C, 0x1D):
                color = (0, 0, 255)
            elif addr.bank() == 0x16 and addr.virtual() >= 0x5700:
                color = (0, 0, 255)
            elif addr.bank() == 0x09 and addr.virtual() >= 0x6700:
                color = (0, 0, 255)
            elif proj.rom.get(addr) == 0xFF:
                color = (0, 0, 127)
            else:
                color = (0, 0, 0)
            x = i % width
            y = i // width
            img.putpixel((x, y), color)

        c = self.connection.cursor()
        c.execute('select addr, length from procs order by addr')
        for addr, length in c.fetchall():
            for i in range(length):
                byte_addr = addr.offset(i).physical()

                x = byte_addr % width
                y = byte_addr // width
                color = (0, 255, 0)
                img.putpixel((x, y), color)

        c.close()

        img.save('data/ownership.png')
        print('image saved')
コード例 #8
0
ファイル: database.py プロジェクト: amorri40/awake
    def produce_map(self, proj):

        romsize = 512*1024
        width = 256
        height = romsize/width

        import Image
        img = Image.new('RGB', (width, height))

        for i in range(512*1024):
            addr = address.fromPhysical(i)
            if addr.bank() in (0x08, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x1C, 0x1D):
                color = (0, 0, 255)
            elif addr.bank() == 0x16 and addr.virtual() >= 0x5700:
                color = (0, 0, 255)
            elif addr.bank() == 0x09 and addr.virtual() >= 0x6700:
                color = (0, 0, 255)
            elif proj.rom.get(addr) == 0xFF:
                color = (0, 0, 127)
            else:
                color = (0, 0, 0)
            x = i % width
            y = i // width
            img.putpixel((x, y), color)

        c = self.connection.cursor()
        c.execute('select addr, length from procs order by addr')
        for addr, length in c.fetchall():
            for i in range(length):
                byte_addr = addr.offset(i).physical()

                x = byte_addr % width
                y = byte_addr // width
                color = (0, 255, 0)
                img.putpixel((x, y), color)

        c.close()

        img.save('data/ownership.png')
        print('image saved')
コード例 #9
0
 def testFromPhysical(self):
     self.assertEquals(str(address.fromPhysical(0x000000)), "0000:0000")
     self.assertEquals(str(address.fromPhysical(0x002000)), "0000:2000")
     self.assertEquals(str(address.fromPhysical(0x004000)), "0001:4000")
     self.assertEquals(str(address.fromPhysical(0x008000)), "0002:4000")
     self.assertEquals(str(address.fromPhysical(0x008888)), "0002:4888")
コード例 #10
0
ファイル: test_address.py プロジェクト: amorri40/awake
 def testFromPhysical(self):
     self.assertEquals(str(address.fromPhysical(0x000000)), "0000:0000")
     self.assertEquals(str(address.fromPhysical(0x002000)), "0000:2000")
     self.assertEquals(str(address.fromPhysical(0x004000)), "0001:4000")
     self.assertEquals(str(address.fromPhysical(0x008000)), "0002:4000")
     self.assertEquals(str(address.fromPhysical(0x008888)), "0002:4888")