Skip to content

Commit

Permalink
Add utils lib with read_ui16 function
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Harvey <ryan.b.harvey@gmail.com>
  • Loading branch information
nihonjinrxs committed Sep 25, 2022
1 parent 03a6d69 commit 7a05b47
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions utils.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
local function read_ui16(byte1, byte2)
assert (0 <= byte1 and byte1 <= 0xff)
assert (0 <= byte2 and byte2 <= 0xff)
local res = bit.bor(
bit.lshift(byte1, 8),
bit.lshift(byte2, 0)
)
return res
end

return {
read_ui16 = read_ui16
}

0 comments on commit 7a05b47

Please sign in to comment.