Skip to content

BizHawkClient: Add BizHawkClient #1978

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 29 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
ba8e9ab
BizHawkClient: Add client and connector
Zunawe Jul 8, 2023
fd0bec4
BizHawkClient: Add launcher component and inno_setup lines
Zunawe Jul 8, 2023
0e4d73e
BizHawkClient: Misc stability updates and small improvements
Zunawe Jul 10, 2023
ebb58a7
BizHawkClient: Add docstrings
Zunawe Jul 10, 2023
de4955e
BizHawkClient: Pull in changes from other branch
Zunawe Jul 15, 2023
8dd4b2e
BizHawkClient: Fix no handler message not displaying after changed ROMs
Zunawe Jul 15, 2023
b3a731b
BizHawkClient: Remove extra print statement from lua
Zunawe Jul 15, 2023
5e61db0
BizHawkClient: Change version command to use raw strings
Zunawe Jul 15, 2023
6c029d2
BizHawkClient: Change script version to single integer
Zunawe Jul 15, 2023
9603f16
BizHawkClient: Add newline to version for lua script
Zunawe Aug 3, 2023
311502b
BizHawkClient: Call send_connect from BizHawkClient's watcher loop
Zunawe Aug 3, 2023
7b30378
BizHawkClient: Add handling for failed request getting script version
Zunawe Aug 3, 2023
eda1308
BizHawkClient: Have base64.lua check lua version explicitly for bit o…
Zunawe Aug 3, 2023
b59429f
BizHawkClient: Update connector script for slightly better errors and…
Zunawe Aug 3, 2023
f05e7e5
BizHawkClient: Remove accidentally added print statements
Zunawe Aug 3, 2023
254a9aa
BizHawkClient: Fix connector server not closing correctly
Zunawe Aug 4, 2023
5190ac3
BizHawkClient: Move some connector code around, some linting
Zunawe Aug 4, 2023
d56404c
BizHawkClient: Small cleanup in lua
Zunawe Aug 4, 2023
d57ed99
BizHawkClient: Lua linting
Zunawe Aug 10, 2023
0929b6c
BizHawkClient: Remove outdated sentences in docstrings
Zunawe Aug 10, 2023
92bd09a
Merge remote-tracking branch 'upstream/main' into bh-client
Zunawe Aug 16, 2023
361c0b5
BizHawkClient: Correctly null check patch file arg
Zunawe Aug 16, 2023
55df7b0
BizHawkClient: Initialize logging
Zunawe Aug 16, 2023
4e2151a
BizHawkClient: Move code to worlds/_bizhawk
Zunawe Aug 29, 2023
f7b5881
BizHawkClient: Add license to connector lua, add types to docs
Zunawe Aug 29, 2023
e87f0b2
BizHawkClient: Add module docstrings
Zunawe Aug 29, 2023
d706c3f
BizHawkClient: Allow clients to define multiple systems
Zunawe Sep 4, 2023
932315b
BizHawkClient: Better logging and handling of interruptions to connec…
Zunawe Sep 9, 2023
97583f1
Merge branch 'main' into bh-client
Berserker66 Oct 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions BizHawkClient.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from __future__ import annotations

import ModuleUpdate
ModuleUpdate.update()

from worlds._bizhawk.context import launch

if __name__ == "__main__":
launch()
119 changes: 119 additions & 0 deletions data/lua/base64.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
-- This file originates from this repository: https://github.com/iskolbin/lbase64
-- It was modified to translate between base64 strings and lists of bytes instead of base64 strings and strings.

local base64 = {}

local extract = _G.bit32 and _G.bit32.extract -- Lua 5.2/Lua 5.3 in compatibility mode
if not extract then
if _G._VERSION == "Lua 5.4" then
extract = load[[return function( v, from, width )
return ( v >> from ) & ((1 << width) - 1)
end]]()
elseif _G.bit then -- LuaJIT
local shl, shr, band = _G.bit.lshift, _G.bit.rshift, _G.bit.band
extract = function( v, from, width )
return band( shr( v, from ), shl( 1, width ) - 1 )
end
elseif _G._VERSION == "Lua 5.1" then
extract = function( v, from, width )
local w = 0
local flag = 2^from
for i = 0, width-1 do
local flag2 = flag + flag
if v % flag2 >= flag then
w = w + 2^i
end
flag = flag2
end
return w
end
end
end


function base64.makeencoder( s62, s63, spad )
local encoder = {}
for b64code, char in pairs{[0]='A','B','C','D','E','F','G','H','I','J',
'K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y',
'Z','a','b','c','d','e','f','g','h','i','j','k','l','m','n',
'o','p','q','r','s','t','u','v','w','x','y','z','0','1','2',
'3','4','5','6','7','8','9',s62 or '+',s63 or'/',spad or'='} do
encoder[b64code] = char:byte()
end
return encoder
end

function base64.makedecoder( s62, s63, spad )
local decoder = {}
for b64code, charcode in pairs( base64.makeencoder( s62, s63, spad )) do
decoder[charcode] = b64code
end
return decoder
end

local DEFAULT_ENCODER = base64.makeencoder()
local DEFAULT_DECODER = base64.makedecoder()

local char, concat = string.char, table.concat

function base64.encode( arr, encoder )
encoder = encoder or DEFAULT_ENCODER
local t, k, n = {}, 1, #arr
local lastn = n % 3
for i = 1, n-lastn, 3 do
local a, b, c = arr[i], arr[i + 1], arr[i + 2]
local v = a*0x10000 + b*0x100 + c
local s
s = char(encoder[extract(v,18,6)], encoder[extract(v,12,6)], encoder[extract(v,6,6)], encoder[extract(v,0,6)])
t[k] = s
k = k + 1
end
if lastn == 2 then
local a, b = arr[n-1], arr[n]
local v = a*0x10000 + b*0x100
t[k] = char(encoder[extract(v,18,6)], encoder[extract(v,12,6)], encoder[extract(v,6,6)], encoder[64])
elseif lastn == 1 then
local v = arr[n]*0x10000
t[k] = char(encoder[extract(v,18,6)], encoder[extract(v,12,6)], encoder[64], encoder[64])
end
return concat( t )
end

function base64.decode( b64, decoder )
decoder = decoder or DEFAULT_DECODER
local pattern = '[^%w%+%/%=]'
if decoder then
local s62, s63
for charcode, b64code in pairs( decoder ) do
if b64code == 62 then s62 = charcode
elseif b64code == 63 then s63 = charcode
end
end
pattern = ('[^%%w%%%s%%%s%%=]'):format( char(s62), char(s63) )
end
b64 = b64:gsub( pattern, '' )
local t, k = {}, 1
local n = #b64
local padding = b64:sub(-2) == '==' and 2 or b64:sub(-1) == '=' and 1 or 0
for i = 1, padding > 0 and n-4 or n, 4 do
local a, b, c, d = b64:byte( i, i+3 )
local s
local v = decoder[a]*0x40000 + decoder[b]*0x1000 + decoder[c]*0x40 + decoder[d]
table.insert(t,extract(v,16,8))
table.insert(t,extract(v,8,8))
table.insert(t,extract(v,0,8))
end
if padding == 1 then
local a, b, c = b64:byte( n-3, n-1 )
local v = decoder[a]*0x40000 + decoder[b]*0x1000 + decoder[c]*0x40
table.insert(t,extract(v,16,8))
table.insert(t,extract(v,8,8))
elseif padding == 2 then
local a, b = b64:byte( n-3, n-2 )
local v = decoder[a]*0x40000 + decoder[b]*0x1000
table.insert(t,extract(v,16,8))
end
return t
end

return base64
Loading