#NEWLINE# def compose_file( input , output = None , path = None , asm = False ) : #NEWLINE# #INDENT# from os.path import dirname , realpath #NEWLINE# f = open ( input ) #NEWLINE# code = f . read ( ) #NEWLINE# f . close ( ) #NEWLINE# if ( path is None ) : #NEWLINE# #INDENT# path = ( dirname ( realpath ( input ) ) + '/' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( path [ ( - 1 ) ] != '/' ) : #NEWLINE# #INDENT# path += '/' #NEWLINE# #UNINDENT# #UNINDENT# if ( output is None ) : #NEWLINE# #INDENT# output = 'output.nes' #NEWLINE# #UNINDENT# game = compose ( code ) #NEWLINE# asmcode = game . to_asm ( ) #NEWLINE# if asm : #NEWLINE# #INDENT# asmfile = open ( 'output.asm' , 'w' ) #NEWLINE# asmfile . write ( asmcode ) #NEWLINE# asmfile . close ( ) #NEWLINE# #UNINDENT# opcodes = nes_compile ( asmcode , path ) #NEWLINE# pynes . write_bin_code ( opcodes , input )