Example #1
0

def UtoS(n):
    if n < 0x80:
        return n
    return -(0x100 - n)


disasmd = {}
if __name__ == "__main__":
    rom = ROM()
    with open('pacman.nes', 'rb') as f:
        rom.load(f)
    #rom.prgbanks[0][0x30C3:0x30C8]=[0xA2,0x00,0xA0,0x00,0xA1,0xAA,0xB1,0x55,0x60]
    labels = {
        rom.read16(0xFFFA): ['nmi', CODE, False],
        rom.read16(0xFFFC): ['rst', CODE, False],
        rom.read16(0xFFFE): ['irq', CODE, False]
    }
    #labels={rom.read16(0xFFFC):['rst',CODE,False]}
    #labels={0xF0C3:['rst',CODE,False]}
    toprocess = [i for i in labels.keys()]
    blocks = {}
    jumptables = [[0xC267, 4], [0xC52E, 12], [0xC7A1, 3], [0xCAD7, 9],
                  [0xD40E, 4], [0xD596, 5], [0xD601, 4], [0xD6DE, 4]]
    while len(toprocess) > 0:
        k = toprocess.pop()
        if k in blocks:
            continue
        b1 = None
        for i in blocks.values():
Example #2
0
JTT=4
JT=8
CC=16
PC=32

def UtoS(n):
	if n<0x80:
		return n
	return -(0x100-n)

disasmd={}
if __name__=="__main__":
	rom=ROM()
	with open('C:\\users\\Andrew.Sentman\\workspace\\AIIEmu\\tests\\pacman.nes','rb') as f:
		rom.load(f)
	labels={rom.read16(0xFFFA):['nmi',CODE,False],rom.read16(0xFFFD):['rst',CODE,False],rom.read16(0xFFFE):['irq',CODE,False]}
	jumptables=[[0xC267,4],[0xC52E,12],[0xC7A1,3],[0xCAD7,9],[0xD40E,4],[0xD596,5],[0xD601,4],[0xD6DE,4]]
	byteflags=[0]*0x10000
	for i in jumptables:
		for j in xrange(i[0],i[0]+i[1]*2):
			byteflags[j]|=JT
		for j in xrange(i[1]):
			taddr=rom.read16(i[0]+j*2)
			if taddr not in labels:
				labels[taddr]=['__'+hex(taddr),CODE|JTT,False]
			else:
				labels[taddr][1]|=CODE|JTT
	#print labels
	plen=0
	while len(labels)>plen:
		plen=len(labels)
Example #3
0
			return False
		if addr>=self.endaddr:
			return False
		return True
def UtoS(n):
	if n<0x80:
		return n
	return -(0x100-n)

disasmd={}
if __name__=="__main__":
	rom=ROM()
	with open('pacman.nes','rb') as f:
		rom.load(f)
	#rom.prgbanks[0][0x30C3:0x30C8]=[0xA2,0x00,0xA0,0x00,0xA1,0xAA,0xB1,0x55,0x60]
	labels={rom.read16(0xFFFA):['nmi',CODE,False],rom.read16(0xFFFC):['rst',CODE,False],rom.read16(0xFFFE):['irq',CODE,False]}
	#labels={rom.read16(0xFFFC):['rst',CODE,False]}
	#labels={0xF0C3:['rst',CODE,False]}
	toprocess=[i for i in labels.keys()]
	blocks={}
	jumptables=[[0xC267,4],[0xC52E,12],[0xC7A1,3],[0xCAD7,9],[0xD40E,4],[0xD596,5],[0xD601,4],[0xD6DE,4]]
	while len(toprocess)>0:
		k=toprocess.pop()
		if k in blocks:
			continue
		b1=None
		for i in blocks.values():
			if i.contains(k):
				b1,b2=i.split(k)
				break
		if b1 is not None: