1. 11

  2. 3

    Bitwise operations in Lua are a bit of a pain unfortunately. I will probably introduce a more convenient API to access 16 bit values.

    Maybe you could just update to Lua 5.3, which has bitwise operators.

    I am curious why you went with 5.2 in the first place. Maybe in prevision for LuaJIT?

    1. 3

      For what it’s worth, LuaJIT includes the Lua BitOp module. BitOp is also available as a standard C module for Lua 5.1/5.2, so you can get a consistent API and semantics across both implementations. I have only used it very briefly, but it seems to be working rather well.

      1. 4

        It is the same kind of API as bit32, unfortunately. The advantage of operators is that instead of this:

        v = bit32.bor(cpu.memory[0xfffc], bit32.lshift(cpu.memory[0xfffd], 8))

        you write this:

        v = cpu.memory[0xfffc] | cpu.memory[0xfffd] << 8
        1. 2

          I’m on 5.2 (and soon even 5.1) indeed so that i can give LuaJIT a try. If that does not work out or if the speed improvements are not worth it then I will probably just move to 5.3.

    2. 2

      Pretty cool idea to tie a scripting API in to what is shaping up to be a fairly well-equipped Apple II emulator. Who needs a Game Genie?