summaryrefslogtreecommitdiffstats
path: root/dos/gen_kfast.py
blob: 9fd160a4753a1d1db8422a72f83db1989d7ceb5d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env python3
#
# Generate KFAST.COM DOS executable
# to maximize keyboard repeat rate and
# to minimize keyboard repeat delay.
#

import sys

if len(sys.argv) == 2:
    target = sys.argv[1]
else:
    target = "KFAST.COM"

with open(target, "bw") as f:
    # mov ax, 0305h
    f.write(b"\xB8\x05\x03")
    # mov bx, auto_repeat
    bh = 0  # 0, 1, 2, 3 -> 1/4, 1/2, 3/4, or 1 s delay
    bl = 0  # 0 .. 0x1F -> 30/s .. 2/s rate
    f.write(b"\xBB%c%c" % (bl, bh))
    # int 16h
    f.write(b"\xCD\x16")
    # mov ah, 4ch
    f.write(b"\xB4\x4C")
    # int 21h
    f.write(b"\xCD\x21")

# vim: ts=4 sw=4 expandtab
bues.ch cgit interface