@@ -1438,7 +1438,7 @@ def assemble(input_):
14381438 return gl .has_errors
14391439
14401440
1441- def generate_binary (outputfname , format_ , progname = '' ):
1441+ def generate_binary (outputfname , format_ , progname = '' , binary_files = None ):
14421442 """ Outputs the memory binary to the
14431443 output filename using one of the given
14441444 formats: tap, tzx or bin
@@ -1449,6 +1449,14 @@ def generate_binary(outputfname, format_, progname=''):
14491449 if gl .has_errors :
14501450 return
14511451
1452+ if binary_files is None :
1453+ binary_files = []
1454+
1455+ bin_blocks = []
1456+ for fname in binary_files :
1457+ with api .utils .open_file (fname ) as f :
1458+ bin_blocks .append ((os .path .basename (fname ), f .read ()))
1459+
14521460 if AUTORUN_ADDR is None :
14531461 AUTORUN_ADDR = org
14541462
@@ -1476,6 +1484,9 @@ def generate_binary(outputfname, format_, progname=''):
14761484 t .save_program ('loader' , program .bytes , line = 1 ) # Put line 0 to protect against MERGE
14771485
14781486 t .save_code (progname , org , binary )
1487+ for name , block in bin_blocks :
1488+ t .save_code (name , 0 , block )
1489+
14791490 t .dump (outputfname )
14801491
14811492 elif format_ == 'tap' :
@@ -1486,6 +1497,9 @@ def generate_binary(outputfname, format_, progname=''):
14861497 t .save_program ('loader' , program .bytes , line = 1 ) # Put line 0 to protect against MERGE
14871498
14881499 t .save_code (progname , org , binary )
1500+ for name , block in bin_blocks :
1501+ t .save_code (name , 0 , block )
1502+
14891503 t .dump (outputfname )
14901504
14911505 else :
0 commit comments