Add Lua migration helper library for bitwise ops

see 49cd836e1, #3485
put `bit = (require "migration_helpers").EmuHawk_pre_2_9_bit();` at top of file
can now easily add helpers for migrating from other emulators
This commit is contained in:
YoshiRulz 2022-12-11 13:18:00 +10:00
parent cbb335fec2
commit c7781d1c17
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
1 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,22 @@
local helpers = {};
helpers.EmuHawk_pre_2_9_bit = function()
local wrapped_bit = {
band = function(val, amt) return val & amt; end,
bnot = function(val) return ~val; end,
bor = function(val, amt) return val | amt; end,
bxor = function(val, amt) return val ~ amt; end, -- not a typo
lshift = function(val, amt) return val << amt; end,
rol = bit.rol,
ror = bit.ror,
rshift = function(val, amt) return val >> amt; end,
arshift = bit.arshift,
check = bit.check,
set = bit.set,
clear = bit.clear,
byteswap_16 = bit.byteswap_16,
byteswap_32 = bit.byteswap_32,
byteswap_64 = bit.byteswap_64,
};
return wrapped_bit;
end;
return helpers;