Lua - fixed zapper.read() to read movie data if a movie is playing. Also changed the struct values to x,y,fire. This breaks lua scripts that used it previous, sorry. Fixed the zapper lua scripts to be compatible with the new zapper code. Updated documentation to reflect this change.

[[Split portion of a mixed commit.]]
This commit is contained in:
adelikat 2010-03-28 04:47:02 +00:00
parent bd7bc4effd
commit 4cf0532e30
6 changed files with 36 additions and 22 deletions

View File

@ -1,3 +1,4 @@
28-march-2010 - adelikat - lua - fixed zapper.read() to read movie data if a movie is playing. Also changed the struct values to x,y,fire. This breaks lua scripts that used it previous, sorry.
04-march-2010 - prockguy - added menu buttons for loading nsf files
03-march-2010 - adelikat - Win32 - If .fm2 drag & dropped with no ROM load, the open ROM dialog will appear
03-march-2010 - prockguy - fceux - now prints the name of the mapper on rom load

View File

@ -17,13 +17,17 @@ else
color = "white"
end
--gui.text(1,1,"X: " .. zap.x)
--gui.text(1,9,"Y: " .. zap.y)
--gui.text(1,17,"Click: " .. zap.fire)
--Draw bull's eye
gui.box(zap.xmouse-1,zap.ymouse-1,zap.xmouse+1,zap.ymouse+1,"clear","red")
gui.box(zap.xmouse-6,zap.ymouse-6,zap.xmouse+6,zap.ymouse+6,"clear",color)
gui.box(zap.xmouse-12,zap.ymouse-12,zap.xmouse+12,zap.ymouse+12,"clear",color)
gui.line(zap.xmouse-12,zap.ymouse-12,zap.xmouse+12,zap.ymouse+12,color)
gui.line(zap.xmouse+12,zap.ymouse-12,zap.xmouse-12,zap.ymouse+12,color)
gui.pixel(zap.xmouse,zap.ymouse,"red")
gui.box(zap.x-1,zap.y-1,zap.x+1,zap.y+1,"clear","red")
gui.box(zap.x-6,zap.y-6,zap.x+6,zap.y+6,"clear",color)
gui.box(zap.x-12,zap.y-12,zap.x+12,zap.y+12,"clear",color)
gui.line(zap.x-12,zap.y-12,zap.x+12,zap.y+12,color)
gui.line(zap.x+12,zap.y-12,zap.x-12,zap.y+12,color)
gui.pixel(zap.x,zap.y,"red")
emu.frameadvance()
end

View File

@ -10,7 +10,7 @@ local Z_MAX = 60 --maximum amount of boxes on screen
local zbuf = {}
local zindex = 1
local timer = 0
local lastclick = zapper.read().click
local lastclick = zapper.read().fire
local lastx = zapper.read().x
local lasty = zapper.read().y
@ -31,9 +31,9 @@ end
while(true) do
local x = zapper.read().xmouse
local y = zapper.read().ymouse
local click = zapper.read().click
local x = zapper.read().x
local y = zapper.read().y
local click = zapper.read().fire
--gui.text(0, 8, string.format("x=%d",x));
--gui.text(0, 18, string.format("y=%d",y));
--gui.text(0, 28, string.format("click=%d",click));

Binary file not shown.

View File

@ -2069,21 +2069,30 @@ static int zapper_read(lua_State *L){
lua_newtable(L);
extern void GetMouseData(uint32 (&md)[3]);
uint32 MouseData[3];
GetMouseData (MouseData);
int x = MouseData[0];
int y = MouseData[1];
int click = MouseData[2]; ///adelikat TODO: remove the ability to store the value 2? Since 2 is right-clicking and not part of zapper input and is used for context menus
extern void GetMouseData(uint32 (&md)[3]); //adelikat: shouldn't this be ifdef'ed for Win32?
int x,y,click;
if (FCEUMOV_IsPlaying())
{
x = currMovieData.records[currFrameCounter].zappers[1].x; //adelikat: Used hardcoded port 1 since as far as I know, only port 1 is valid for zappers
y = currMovieData.records[currFrameCounter].zappers[1].y;
click = currMovieData.records[currFrameCounter].zappers[1].b;
}
else
{
uint32 MouseData[3];
GetMouseData (MouseData);
x = MouseData[0];
y = MouseData[1];
click = MouseData[2];
if (click > 1)
click = 1; //adelikat: This is zapper.read() thus should only give valid zapper input (instead of simply mouse input
}
lua_pushinteger(L, x);
lua_setfield(L, -2, "xmouse");
lua_setfield(L, -2, "x");
lua_pushinteger(L, y);
lua_setfield(L, -2, "ymouse");
lua_setfield(L, -2, "y");
lua_pushinteger(L, click);
lua_setfield(L, -2, "click");
lua_setfield(L, -2, "fire");
return 1;
}

Binary file not shown.