-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlhashdos.lua
More file actions
34 lines (26 loc) · 793 Bytes
/
lhashdos.lua
File metadata and controls
34 lines (26 loc) · 793 Bytes
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
30
31
32
33
34
-- gonzalez, j | december 2017
-- lhashdos.lua
local ffi = require 'ffi'
local bit = require 'bit'
local char_array
do
math.randomseed(os.time())
char_array = ffi.new 'char[15]'
local lowest_char = math.random((' o'):byte(1, 2))
for i = lowest_char, lowest_char + 15 do
char_array[i - lowest_char] = i
end
ffi.cdef 'typedef char collidable[32];'
end
local function get(spacer, outputs_desired, restart_position)
local bit_rshift = bit.rshift
local start = restart_position or 1
local buffer = ffi.new('collidable[?]', outputs_desired)
ffi.fill(buffer, ffi.sizeof(buffer), spacer:byte())
for buf_pos = 0, outputs_desired - start do
for offset = 0, 30, 2 do
buffer[buf_pos][offset] = char_array[bit_rshift(buf_pos + start, offset) % 15]
end
end
return buffer
end