diff --git a/changelog.txt b/changelog.txt index f0b8f69b..f096e361 100644 --- a/changelog.txt +++ b/changelog.txt @@ -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 diff --git a/output/luaScripts/ZapperDisplay.lua b/output/luaScripts/ZapperDisplay.lua index 2a3c4256..51bc4aab 100644 --- a/output/luaScripts/ZapperDisplay.lua +++ b/output/luaScripts/ZapperDisplay.lua @@ -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 \ No newline at end of file diff --git a/output/luaScripts/ZapperFun.lua b/output/luaScripts/ZapperFun.lua index dd09256d..ab3dc4ae 100644 --- a/output/luaScripts/ZapperFun.lua +++ b/output/luaScripts/ZapperFun.lua @@ -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)); diff --git a/src/drivers/win/help/fceux.chm b/src/drivers/win/help/fceux.chm index fc641c59..d5794e0a 100644 Binary files a/src/drivers/win/help/fceux.chm and b/src/drivers/win/help/fceux.chm differ diff --git a/src/lua-engine.cpp b/src/lua-engine.cpp index 6a98c380..6b1aebce 100644 --- a/src/lua-engine.cpp +++ b/src/lua-engine.cpp @@ -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; } diff --git a/vc/Help/fceux.hnd b/vc/Help/fceux.hnd index b9c59e3f..bd8e8984 100644 Binary files a/vc/Help/fceux.hnd and b/vc/Help/fceux.hnd differ