2626from api import global_ as gl
2727import api .utils
2828import zxbpp
29+ import outfmt
2930
3031LEXER = asmlex .Lexer ()
3132
@@ -1438,7 +1439,7 @@ def assemble(input_):
14381439 return gl .has_errors
14391440
14401441
1441- def generate_binary (outputfname , format_ , progname = '' , binary_files = None ):
1442+ def generate_binary (outputfname , format_ , progname = '' , binary_files = None , headless_binary_files = None ):
14421443 """ Outputs the memory binary to the
14431444 output filename using one of the given
14441445 formats: tap, tzx or bin
@@ -1452,11 +1453,19 @@ def generate_binary(outputfname, format_, progname='', binary_files=None):
14521453 if binary_files is None :
14531454 binary_files = []
14541455
1456+ if headless_binary_files is None :
1457+ headless_binary_files = []
1458+
14551459 bin_blocks = []
14561460 for fname in binary_files :
14571461 with api .utils .open_file (fname ) as f :
14581462 bin_blocks .append ((os .path .basename (fname ), f .read ()))
14591463
1464+ headless_bin_blocks = []
1465+ for fname in headless_binary_files :
1466+ with api .utils .open_file (fname ) as f :
1467+ headless_bin_blocks .append (f .read ())
1468+
14601469 if AUTORUN_ADDR is None :
14611470 AUTORUN_ADDR = org
14621471
@@ -1476,29 +1485,17 @@ def generate_binary(outputfname, format_, progname='', binary_files=None):
14761485 else :
14771486 program .add_line ([['REM' ], ['RANDOMIZE' , program .token ('USR' ), AUTORUN_ADDR ]])
14781487
1479- if format_ == 'tzx' :
1480- import outfmt
1481- t = outfmt .TZX ()
1482-
1483- if OPTIONS .use_loader .value :
1484- t .save_program ('loader' , program .bytes , line = 1 ) # Put line 0 to protect against MERGE
1485-
1486- t .save_code (progname , org , binary )
1487- for name , block in bin_blocks :
1488- t .save_code (name , 0 , block )
1489-
1490- t .dump (outputfname )
1491-
1492- elif format_ == 'tap' :
1493- import outfmt
1494- t = outfmt .TAP ()
1488+ if format_ in ('tap' , 'tzx' ):
1489+ t = {'tap' : outfmt .TAP , 'tzx' : outfmt .TZX }[format_ ]()
14951490
14961491 if OPTIONS .use_loader .value :
14971492 t .save_program ('loader' , program .bytes , line = 1 ) # Put line 0 to protect against MERGE
14981493
14991494 t .save_code (progname , org , binary )
15001495 for name , block in bin_blocks :
15011496 t .save_code (name , 0 , block )
1497+ for block in headless_bin_blocks :
1498+ t .standard_block (block )
15021499
15031500 t .dump (outputfname )
15041501
0 commit comments