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

luaengine: add HUD-like capabilities #90

Merged
merged 2 commits into from Jan 5, 2015

Conversation

Projects
None yet
2 participants
@lucab
Contributor

lucab commented Dec 25, 2014

These commits add a way to let LUA scripts register a callback
to be invoked before rendering each frame.
This callback typically makes use of other provided methods to draw
custom graphics on top of each frame.

The idea is to let LUA script provide HUD-like features, mostly used for
trainings and TAS runs development.

Signed-off-by: Luca Bruno lucab@debian.org

lucab added some commits Dec 25, 2014

luaengine: add screen drawing/HUD capabilities
This commit allows LUA scripts to implement HUD capabilities,
by overlaying elements (lines, boxes, text) to screen.
Mostly used to draw custom graphic helpers for trainings and
TAS runs development.

Signed-off-by: Luca Bruno <lucab@debian.org>
luaengine: add frame hooking support
This commit adds a method to let LUA scripts register a callback
to be invoked before rendering each frame.
This callback typically makes use of screen drawing methods to
draw a custom HUD on top of each frame.

Signed-off-by: Luca Bruno <lucab@debian.org>
@lucab

This comment has been minimized.

Contributor

lucab commented Dec 25, 2014

This is v2 of #71, OO-ified after some suggestions from @galibert.

Major changes:

  • now using luabridge, more C++ friendly
  • available screens now enumerable via manager():machine().screens
  • instance methods to draw boxes/lines/text on a single screen separately
@lucab

This comment has been minimized.

Contributor

lucab commented Dec 25, 2014

Just as a note, this is a very dumb LUA autoboot_script I'm using to test all of lua_engine current capabilities:

local g = {
        x = 0,
        y = 0
}

local mem=manager:machine().devices[":maincpu"].spaces["program"]
local gui=manager:machine().screens[":screen"]

emu.sethook(function()
        gui:draw_text(g.x, g.y, mem:read_i16(0x0000C000))
        gui:draw_box(20,20, g.x, g.y, 0, 0xffff0000)
        gui:draw_line(20,20, g.x, g.y, 0xff0000ff)
        g.x = g.x + 1;
        g.y = g.y + 1;
        if (g.x+5) >= gui:width() then
            g.x = 0
        end
        if g.y >= gui:height() then
            g.y = 0
        end
end, "frame")
@lucab

This comment has been minimized.

Contributor

lucab commented Jan 5, 2015

@galibert @mmicko can I get a review on this?

@galibert

This comment has been minimized.

Member

galibert commented Jan 5, 2015

Eventually the hook should be per-screen, because different screens can
theorically gave different frame rates. But the core is currently fucked
in that area, so you can't do it.

OG.

On Mon, Jan 5, 2015 at 5:54 PM, Luca Bruno notifications@github.com wrote:

@galibert https://github.com/galibert @mmicko
https://github.com/mmicko can I get a review on this?


Reply to this email directly or view it on GitHub
#90 (comment).

galibert added a commit that referenced this pull request Jan 5, 2015

Merge pull request #90 from lucab/lucab/mame-lua/gui-v2
luaengine: add HUD-like capabilities

@galibert galibert merged commit f67e16a into mamedev:master Jan 5, 2015

@lucab lucab deleted the lucab:lucab/mame-lua/gui-v2 branch Jan 6, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment