gen_kfast.py 622 B

123456789101112131415161718192021222324252627282930
  1. #!/usr/bin/env python3
  2. #
  3. # Generate KFAST.COM DOS executable
  4. # to maximize keyboard repeat rate and
  5. # to minimize keyboard repeat delay.
  6. #
  7. import sys
  8. if len(sys.argv) == 2:
  9. target = sys.argv[1]
  10. else:
  11. target = "KFAST.COM"
  12. with open(target, "bw") as f:
  13. # mov ax, 0305h
  14. f.write(b"\xB8\x05\x03")
  15. # mov bx, auto_repeat
  16. bh = 0 # 0, 1, 2, 3 -> 1/4, 1/2, 3/4, or 1 s delay
  17. bl = 0 # 0 .. 0x1F -> 30/s .. 2/s rate
  18. f.write(b"\xBB%c%c" % (bl, bh))
  19. # int 16h
  20. f.write(b"\xCD\x16")
  21. # mov ah, 4ch
  22. f.write(b"\xB4\x4C")
  23. # int 21h
  24. f.write(b"\xCD\x21")
  25. # vim: ts=4 sw=4 expandtab