loadertpl.py 622 B

1234567891011121314151617181920212223242526
  1. #!/usr/bin/env python3
  2. template = """\
  3. 10 CLEAR 0,&H%s:BLOAD"%s"\n\
  4. 20 DEFUSR=&H%s\n\
  5. 30 A=USR(0)\n\
  6. 40 B=PEEK(&HF975)+256*PEEK(&HF976)+65536*PEEK(&HF977)\n\
  7. 50 ?B,A\n\
  8. """
  9. fnames = {'cas':'CAS:VDPtst', 'dsk':'vdptest.bin'}
  10. import sys
  11. def hx(n): return hex(n)[2:].upper()
  12. def main():
  13. if len(sys.argv) < 3 or sys.argv[1].lower() not in fnames:
  14. sys.stderr.write("Usage: python3 loadertpl.py {cas|dsk} <addr>\n")
  15. addr = int(sys.argv[2], 0)
  16. fname = fnames[sys.argv[1].lower()]
  17. tpl = template.replace('\n','\r\n')
  18. sys.stdout.buffer.write(
  19. (tpl % (hx(addr - 1), fname, hx(addr))).encode('latin1'))
  20. main()