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

Introduce Lua Support #148

Merged
merged 1 commit into from Sep 19, 2017

Conversation

Projects
None yet
1 participant
@st3fan
Owner

st3fan commented Sep 16, 2017

This patch lays the foundation for Lua support. It pulls in Lua 5.2 and adds a --script argument to two.

It also exposes a cpu global with onBeforeExecuteInstruction and onAfterExecuteInstruction functions. These allow you to register callbacks around individual instruction execution. The same object also has properties like a, x, y, s, sp and pc - which can all be set/changed too.

Example of a small Lua script:

--
-- Intercept JSR COUT calls and turn A-Z into inverse. The key code is
-- in the accumulator so we can simply see if it is in the range we
-- are interested in and then shift it to the inverse character range.
--

JSR = 0x20
COUT = 0xfded

cpu:onBeforeExecuteInstruction(JSR, function(cpu, opcode, operand)
  if operand == COUT then
     if cpu.a >= 0xc1 and cpu.a <= 0xda then
        cpu.a = cpu.a - 0xC0
     end
  end
end)

@st3fan st3fan added two lua labels Sep 16, 2017

@st3fan st3fan merged commit a88c4a7 into master Sep 19, 2017

0 of 2 checks passed

continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
continuous-integration/travis-ci/push The Travis CI build is in progress
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment