# Path: awake/address.py
# BANK_SIZE = 0x4000
# class BadAddressException(Exception):
# class Address(object):
#     def __init__(self, addr):
#     def __str__(self):
# def fromVirtual(virtual):
# def fromVirtualAndBank(virtual, bank):
# def fromVirtualAndCurrent(virtual, current):
# def fromPhysical(physical):
# def fromConventional(conventional):
#     def __init__(self, address):
#     def virtual(self):
#     def bank(self):
#     def isAmbiguous(self):
#     def inBankedSpace(self):
#     def inPhysicalMem(self):
#     def physical(self):
#     def offset(self, offset):
#     def withBankSpecified(self, bank):
#     def __lt__(self, other):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def __hash__(self):
#     def __str__(self):
#     def __repr__(self):


from collections import defaultdict
from PIL import Image
from awake import address
            elif q < 128:
                intensity = 64
            elif q < 512:
                intensity = 128
            elif q < 2048:
                intensity = 192
            else:
                intensity = 255
            """
            intensity = 0

            f.write('    ' + addr_symbol(addr) + ' [fillcolor="#FF{0:02x}{0:02x}"];\n'.format(255-intensity))
            f.write('    ' + addr_symbol(addr) + ' [style="filled"];\n')

            for c in info.calls:
                f.write('    ' + addr_symbol(addr) + ' -> ' + addr_symbol(c) + ';\n')
            for c in info.tail_calls:
                f.write('    ' + addr_symbol(addr) + ' -> ' + addr_symbol(c) + ' [color="blue"];\n'
)
        f.write("}\n")

def save_dot_for_bank(database, bank):
    bank_name = '{:04X}'.format(bank)

    with open('data/bank'+bank_name+'.dot', 'w') as f:
        f.write("digraph crossref {\n")

        cur = database.connection.cursor()
        cur.execute('select addr from procs where substr(addr, 0, 5)=?', (bank_name,))
        for proc_result in cur.fetchall():

# Path: awake/address.py
# BANK_SIZE = 0x4000
# class BadAddressException(Exception):
# class Address(object):
#     def __init__(self, addr):
#     def __str__(self):
# def fromVirtual(virtual):
# def fromVirtualAndBank(virtual, bank):
# def fromVirtualAndCurrent(virtual, current):
# def fromPhysical(physical):
# def fromConventional(conventional):
#     def __init__(self, address):
#     def virtual(self):
#     def bank(self):
#     def isAmbiguous(self):
#     def inBankedSpace(self):
#     def inPhysicalMem(self):
#     def physical(self):
#     def offset(self, offset):
#     def withBankSpecified(self, bank):
#     def __lt__(self, other):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def __hash__(self):
#     def __str__(self):
#     def __repr__(self):


# Path: awake/graph.py
from collections import defaultdict
from PIL import Image
from awake import address

            elif q < 128:
                intensity = 64
            elif q < 512:
                intensity = 128
            elif q < 2048:
                intensity = 192
            else:
                intensity = 255
            """
            intensity = 0

            f.write('    ' + addr_symbol(addr) + ' [fillcolor="#FF{0:02x}{0:02x}"];\n'.format(255-intensity))
            f.write('    ' + addr_symbol(addr) + ' [style="filled"];\n')

            for c in info.calls:
                f.write('    ' + addr_symbol(addr) + ' -> ' + addr_symbol(c) + ';\n')
            for c in info.tail_calls:
                f.write('    ' + addr_symbol(addr) + ' -> ' + addr_symbol(c) + ' [color="blue"];\n'
)
        f.write("}\n")

def save_dot_for_bank(database, bank):
    bank_name = '{:04X}'.format(bank)

    with open('data/bank'+bank_name+'.dot', 'w') as f:
        f.write("digraph crossref {\n")

        cur = database.connection.cursor()
        cur.execute('select addr from procs where substr(addr, 0, 5)=?', (bank_name,))
        for proc_result in cur.fetchall():

            addr = address.fromConventional(proc_result[0])