Пример #1
0
				inloc=NodeLocImmediate(self.bytes[1])
			if self.op[0]=='AND':
				ast.append(NodeAssign(NodeLocReg('A'),NodeAND(NodeLocReg('A'),inloc)))
				ast.append(NodeAssign(NodeLocReg('fS'),NodeBit(NodeLocReg('A'),7)))
				ast.append(NodeAssign(NodeLocReg('fZ'),NodeEqual(NodeLocReg('A'),NodeLocImmediate(0))))
				return ast
			if self.op[0] in ['LDA','LDX','LDY']:
				ast.append(NodeAssign(NodeLocReg(self.op[0][2]),inloc))
				return ast
		if self.op[5]==STO:
			if self.op[1]==ZP:
				return [NodeWrite(NodeLocAbsolute(self.bytes[1]),NodeLocReg(self.op[0][2]))]
		if self.op[5]==JSR:
			return [NodeBranch(NodeLocAbsolute(self.bytes[1]+(self.bytes[2]<<8)))]
		if self.op[5]==JMP:
			if self.op[1]==ABS:
				return [NodeBranch(NodeLocAbsolute(self.bytes[1]+(self.bytes[2]<<8)))]
		if self.op[5]==RTS:
			return [NodeRTS()]
		print self.op[0]
		print 5/0
if __name__=="__main__":
	rom=ROM()
	with open('C:\\users\\Andrew.Sentman\\workspace\\AIIEmu\\tests\\pacman.nes','rb') as f:
		rom.load(f)
	addr=0xc033
	while True:
		op=Opcode()
		addr=op.load(rom,addr)
		print op.genAST()
Пример #2
0

if __name__ == '__main__':
    if len(sys.argv) > 1:
        rom_file_name = sys.argv[1]
    else:
        rom_file_name = 'supermario.nes'

    nes = NES()
    rom = ROM(nes)
    if rom.headercheck(rom_file_name) != True:
        exit()
    nes.rom = rom

    mem = MEMORY(nes)
    rom.load(rom_file_name, mem)
    nes.mem = mem

    cpu = CPU(nes)
    nes.cpu = cpu
    cpu.reset()

    ppu = PPU(nes)
    nes.ppu = ppu
    ppu.reset()

    disp = DISPLAY(nes)
    nes.disp = disp
    disp.init()

    in_put = INPUT(nes)
Пример #3
0
DATA=2
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: