28 lines
558 B
Lua
28 lines
558 B
Lua
|
|
local function queueBit(gate, bit)
|
|
table.insert(gate.queueBits, 1, bit)
|
|
end
|
|
|
|
return function(gate, argv)
|
|
if argv[1]=="\\:" then argv[1] = ";" end
|
|
|
|
local keycode = keyboard_keyToCode[argv[1]]
|
|
if not keycode then return end
|
|
local status = argv[2]=="1"
|
|
|
|
local code = keycode+(status and 128 or 0)
|
|
|
|
if #gate.queueBits > 1024 then return end
|
|
|
|
queueBit(gate, 1)
|
|
for bitidx = 1, 8 do
|
|
local val = bit.band(code, 0x80)
|
|
queueBit(gate, val)
|
|
|
|
code = bit.lshift(code, 1)
|
|
end
|
|
queueBit(gate, 0)
|
|
|
|
Gate.queue(gate, 0)
|
|
end
|