Ejemplo n.º 1
0
    def testDecode(self):
        op = SingleOpcodeDecoder("00000000 1 NOP");
        self.assertEquals(str(op.decode([0], address.fromPhysical(0))), "NOP");

        op = SingleOpcodeDecoder("11100110 2 AND   A, v8");
        self.assertEquals(str(op.decode([0b11100110, 0xfa], address.fromPhysical(0))).strip().upper(), "AND\tA, 0XFA");

        op = SingleOpcodeDecoder("11100000 3 LD    [FF00+v8], A");
        self.assertEquals(str(op.decode([0b11100000, 0xfa], address.fromPhysical(0))).strip().upper(), "LD\t[(V):FFFA], A");

        op = SingleOpcodeDecoder("001FF000 2 JP    v8_rel, #F");
        self.assertEquals(str(op.decode([0b00100000, 0x10], address.fromPhysical(0x100))).strip().upper(), "JP\t0000:0112, FNZ");

        op = SingleOpcodeDecoder("00001000 5 LD16  [v16], SP");
        self.assertEquals(str(op.decode([0b00001000, 0xAA,0xBB], address.fromPhysical(0x100))).strip().upper(), "LD16\t[(V):BBAA], SP");
Ejemplo n.º 2
0
def produce_map(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]

        import disasm

        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 disasm.cur_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'
Ejemplo n.º 3
0
def produce_map():

    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)
        import disasm
        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 disasm.cur_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 = connection.cursor()
    c.execute('select addr, length from procs order by addr')
    for result in c.fetchall():
        addr = address.fromConventional(result[0])
        length = result[1]

        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'