Lua scripts cleanup - deleted some, renamed others, included documentation notes on each

This commit is contained in:
adelikat 2009-03-28 18:08:41 +00:00
parent 88334597eb
commit 0ecbb2dd1a
14 changed files with 65 additions and 532 deletions

View File

@ -1,3 +1,7 @@
--RegisterFind
--written by QFox
--Weeds out RAM addresses along the lines of Cheat Search and Ram Filter. Has some features not present in either of those 2 hardcoded dialogs.
-- v0.1a (far from done!)
-- include some iup stuff and take care of cleanup
require 'auxlib';

View File

@ -1,6 +1,6 @@
-- super mario bros 1 hitbox script
-- Super Mario Bros. (JU) (PRG0) [!].rom
-- by qFox
-- Super Mario Bros. hitbox script
-- Super Mario Bros (JU) (PRG0) [!].nes
-- Written by qFox
-- 28 july 2008
-- This script shows hitboxes of anything that has them

View File

@ -1,6 +1,6 @@
-- SMB1 script by 4matsy. Yay.
-- Super Mario Bros. script by 4matsy.
-- 2008, September 11th.
--Displays the # of lives for Mario and a HP meter for Bowswer
require("shapedefs");

View File

@ -1,11 +1,13 @@
-- unfinished mario bros 2 script
-- Super Mario Bros. 2 USA - Grids & Contents (Unfinished)
-- Super Mario Bros. 2 (U) (PRG0) [!].nes
-- Written by QFox
-- 31 July 2008
-- shows (proper!) grid and contents. disable grid by setting variable to false
-- shows any non-air grid's tile-id
-- can be heavy on light systems
-- Slow! Will be heavy on lighter systems
-- Super Mario Bros. 2 (U) (PRG0) [!].rom
-- qFox
-- 31 july 2008
local angrybirdo = false; -- makes birdo freak, but can skew other creatures with timing :)
local drawgrid = true; -- draws a green grid

View File

@ -1,6 +1,7 @@
-- Teenage Mutant Ninja Turtles (U)[!].rom
-- qFox
-- Written by QFox
-- 31 july 2008
-- Displays Hitboxes, Enemy HP, and various stats on screen
local function box(x1,y1,x2,y2,color)
-- gui.text(50,50,x1..","..y1.." "..x2..","..y2);

View File

@ -0,0 +1,43 @@
--shapedefs
--A Lua script with defined functions for shapes such as hearts.
--Needed for SM-Lives&HPDisplay-4Matsy.lua
local function box(x1,y1,x2,y2,color)
if (x1 > 0 and x1 < 255 and x2 > 0 and x2 < 255 and y1 > 0 and y1 < 241 and y2 > 0 and y2 < 241) then
gui.drawbox(x1,y1,x2,y2,color);
end;
end;
local function text(x,y,str)
if (x > 0 and x < 255 and y > 0 and y < 240) then
gui.text(x,y,str);
end;
end;
local function pixel(x,y,color)
if (x > 0 and x < 255 and y > 0 and y < 240) then
gui.drawpixel(x,y,color);
end;
end;
function drawshape (x,y,str,color)
if str == "heart_5x5" then
box(x+1,y+0,x+1,y+3,color);
box(x+3,y+0,x+3,y+3,color);
box(x+2,y+3,x+2,y+4,color);
box(x+0,y+1,x+4,y+2,color);
end;
if str == "heart_7x7" then
box(x+1,y+0,x+2,y+4,color);
box(x+4,y+0,x+5,y+4,color);
box(x+0,y+1,x+6,y+3,color);
box(x+3,y+2,x+3,y+6,color);
box(x+2,y+5,x+4,y+5,color);
end;
if str == "z2magicjar" then
box(x+0,y+5,x+4,y+6,color);
box(x+1,y+4,x+3,y+7,color);
box(x+1,y+0,x+3,y+0,color);
box(x+2,y+1,x+2,y+3,color);
box(x+3,y+2,x+3,y+2,color);
box(x+4,y+3,x+4,y+3,color);
end;
end;

View File

@ -1,73 +0,0 @@
-- super mario bros 1 hitbox script
-- Super Mario Bros. (JU) (PRG0) [!].rom
-- by qFox
-- 28 july 2008
local function box(x1,y1,x2,y2,color)
-- gui.text(50,50,x1..","..y1.." "..x2..","..y2);
if (x1 > 0 and x1 < 255 and x2 > 0 and x2 < 255 and y1 > 0 and y1 < 224 and y2 > 0 and y2 < 224) then
gui.drawbox(x1,y1,x2,y2,color);
end;
end;
-- hitbox coordinate offsets (x1,y1,x2,y2)
local mario_hb = 0x04AC; -- 1x4
local enemy_hb = 0x04B0; -- 5x4
local coin_hb = 0x04E0; -- 3x4
local fiery_hb = 0x04C8; -- 2x4
local hammer_hb= 0x04D0; -- 9x4
local power_hb = 0x04C4; -- 1x4
-- addresses to check, to see whether the hitboxes should be drawn at all
local mario_ch = 0x000E;
local enemy_ch = 0x000F;
local coin_ch = 0x0030;
local fiery_ch = 0x0024;
local hammer_ch= 0x002A;
local power_ch = 0x0014;
while true do
-- from 0x04AC are about 0x48 addresse that indicate a hitbox
-- different items use different addresses, some share
-- there can for instance only be one powerup on screen at any time (the star in 1.1 gets replaced by the flower, if you get it)
-- we cycle through the animation addresses for each type of hitbox, draw the corresponding hitbox if they are drawn
-- we draw: mario (1), enemies (5), coins (3), hammers (9), powerups (1). (bowser and (his) fireball are considered enemies)
-- mario
if (memory.readbyte(mario_hb) > 0) then box(memory.readbyte(mario_hb),memory.readbyte(mario_hb+1),memory.readbyte(mario_hb+2),memory.readbyte(mario_hb+3), "green"); end;
-- enemies
if (memory.readbyte(enemy_ch ) > 0) then box(memory.readbyte(enemy_hb), memory.readbyte(enemy_hb+1), memory.readbyte(enemy_hb+2), memory.readbyte(enemy_hb+3), "green"); end;
if (memory.readbyte(enemy_ch+1) > 0) then box(memory.readbyte(enemy_hb+4), memory.readbyte(enemy_hb+5), memory.readbyte(enemy_hb+6), memory.readbyte(enemy_hb+7), "green"); end;
if (memory.readbyte(enemy_ch+2) > 0) then box(memory.readbyte(enemy_hb+8), memory.readbyte(enemy_hb+9), memory.readbyte(enemy_hb+10),memory.readbyte(enemy_hb+11), "green"); end;
if (memory.readbyte(enemy_ch+3) > 0) then box(memory.readbyte(enemy_hb+12),memory.readbyte(enemy_hb+13),memory.readbyte(enemy_hb+14),memory.readbyte(enemy_hb+15), "green"); end;
if (memory.readbyte(enemy_ch+4) > 0) then box(memory.readbyte(enemy_hb+16),memory.readbyte(enemy_hb+17),memory.readbyte(enemy_hb+18),memory.readbyte(enemy_hb+19), "green"); end;
-- coins
if (memory.readbyte(coin_ch ) > 0) then box(memory.readbyte(coin_hb), memory.readbyte(coin_hb+1), memory.readbyte(coin_hb+2), memory.readbyte(coin_hb+3), "green"); end;
if (memory.readbyte(coin_ch+1) > 0) then box(memory.readbyte(coin_hb+4), memory.readbyte(coin_hb+5), memory.readbyte(coin_hb+6), memory.readbyte(coin_hb+7), "green"); end;
if (memory.readbyte(coin_ch+2) > 0) then box(memory.readbyte(coin_hb+8), memory.readbyte(coin_hb+9), memory.readbyte(coin_hb+10), memory.readbyte(coin_hb+11), "green"); end;
-- (mario's) fireballs
if (memory.readbyte(fiery_ch ) > 0) then box(memory.readbyte(fiery_hb), memory.readbyte(fiery_hb+1), memory.readbyte(fiery_hb+2), memory.readbyte(fiery_hb+3), "green"); end;
if (memory.readbyte(fiery_ch+1) > 0) then box(memory.readbyte(fiery_hb+4), memory.readbyte(fiery_hb+5), memory.readbyte(fiery_hb+6),memory.readbyte(fiery_hb+7), "green"); end;
-- hammers
if (memory.readbyte(hammer_ch ) > 0) then box(memory.readbyte(hammer_hb), memory.readbyte(hammer_hb+1), memory.readbyte(hammer_hb+2), memory.readbyte(hammer_hb+3), "green"); end;
if (memory.readbyte(hammer_ch+1) > 0) then box(memory.readbyte(hammer_hb+4), memory.readbyte(hammer_hb+5), memory.readbyte(hammer_hb+6), memory.readbyte(hammer_hb+7), "green"); end;
if (memory.readbyte(hammer_ch+2) > 0) then box(memory.readbyte(hammer_hb+8), memory.readbyte(hammer_hb+9), memory.readbyte(hammer_hb+10),memory.readbyte(hammer_hb+11), "green"); end;
if (memory.readbyte(hammer_ch+3) > 0) then box(memory.readbyte(hammer_hb+12),memory.readbyte(hammer_hb+13),memory.readbyte(hammer_hb+14),memory.readbyte(hammer_hb+15), "green"); end;
if (memory.readbyte(hammer_ch+4) > 0) then box(memory.readbyte(hammer_hb+16),memory.readbyte(hammer_hb+17),memory.readbyte(hammer_hb+18),memory.readbyte(hammer_hb+19), "green"); end;
if (memory.readbyte(hammer_ch+5) > 0) then box(memory.readbyte(hammer_hb+20),memory.readbyte(hammer_hb+21),memory.readbyte(hammer_hb+22),memory.readbyte(hammer_hb+23), "green"); end;
if (memory.readbyte(hammer_ch+6) > 0) then box(memory.readbyte(hammer_hb+24),memory.readbyte(hammer_hb+25),memory.readbyte(hammer_hb+26),memory.readbyte(hammer_hb+27), "green"); end;
if (memory.readbyte(hammer_ch+7) > 0) then box(memory.readbyte(hammer_hb+28),memory.readbyte(hammer_hb+29),memory.readbyte(hammer_hb+30),memory.readbyte(hammer_hb+31), "green"); end;
if (memory.readbyte(hammer_ch+8) > 0) then box(memory.readbyte(hammer_hb+32),memory.readbyte(hammer_hb+33),memory.readbyte(hammer_hb+34),memory.readbyte(hammer_hb+35), "green"); end;
-- powerup
if (memory.readbyte(power_ch) > 0) then box(memory.readbyte(power_hb),memory.readbyte(power_hb+1),memory.readbyte(power_hb+2),memory.readbyte(power_hb+3), "green"); end;
gui.text(5,32,"Green rectangles are hitboxes!");
FCEU.frameadvance()
end

View File

@ -1,6 +1,7 @@
-- Tetris - displays block stats and shows hitboxes
-- Written by QFox
-- http://www.datacrystal.org/wiki/Tetris:RAM_map
-- Tetris (U) [!].rom
-- qFox
local function getPiece(n) -- returns table with information about this piece
-- every piece consists of 4 blocks

View File

@ -1,3 +1,5 @@
--x_functions - various functions needed for scripts witten by Xkeeper
--Written by Xkeeper
x_func_version = 5;

View File

@ -1,41 +0,0 @@
require "x_functions";
if not x_requires then
-- Sanity check. If they require a newer version, let them know.
timer = 1;
while (true) do
timer = timer + 1;
for i = 0, 32 do
gui.drawbox( 6, 28 + i, 250, 92 - i, "#000000");
end;
gui.text( 10, 32, string.format("This Lua script requires the x_functions library."));
gui.text( 53, 42, string.format("It appears you do not have it."));
gui.text( 39, 58, "Please get the x_functions library at");
gui.text( 14, 69, "http://xkeeper.shacknet.nu/");
gui.text(114, 78, "emu/nes/lua/x_functions.lua");
warningboxcolor = string.format("%02X", math.floor(math.abs(30 - math.fmod(timer, 60)) / 30 * 0xFF));
gui.drawbox(7, 29, 249, 91, "#ff" .. warningboxcolor .. warningboxcolor);
FCEU.frameadvance();
end;
else
x_requires(4);
end;
while true do
zap = zapper.read();
box(zap['x'] - 5, zap['y'] - 5, zap['x'] + 5, zap['y'] + 5, "#ffffff");
if zap['click'] == 1 then
box(zap['x'] - 7, zap['y'] - 7, zap['x'] + 7, zap['y'] + 7, "#ff0000");
end;
line(zap['x'] - 0, zap['y'] - 9, zap['x'] + 0, zap['y'] + 9, "#ffffff");
line(zap['x'] - 9, zap['y'] - 0, zap['x'] + 9, zap['y'] + 0, "#ffffff");
FCEU.frameadvance();
end

View File

@ -1,337 +0,0 @@
require "x_functions";
if not x_requires then
-- Sanity check. If they require a newer version, let them know.
timer = 1;
while (true) do
timer = timer + 1;
for i = 0, 32 do
gui.drawbox( 6, 28 + i, 250, 92 - i, "#000000");
end;
gui.text( 10, 32, string.format("This Lua script requires the x_functions library."));
gui.text( 53, 42, string.format("It appears you do not have it."));
gui.text( 39, 58, "Please get the x_functions library at");
gui.text( 14, 69, "http://xkeeper.shacknet.nu/");
gui.text(114, 78, "emu/nes/lua/x_functions.lua");
warningboxcolor = string.format("%02X", math.floor(math.abs(30 - math.fmod(timer, 60)) / 30 * 0xFF));
gui.drawbox(7, 29, 249, 91, "#ff" .. warningboxcolor .. warningboxcolor);
FCEU.frameadvance();
end;
else
x_requires(5);
end;
function drawmouse(x, y, click)
if click then
fill = "#cccccc";
else
fill = "#ffffff";
end;
y = y + 1;
for i = 0, 6 do
if i ~= 6 then
line(x + i, y + i, x + i, y + 8 - math.floor(i / 2), fill);
pixel(x + i, y + 8 - math.floor(i / 2), "#000000");
end;
pixel(x + i, y + i - 1, "#000000");
end;
pixel(x + 1, y + 0, "#000000");
line(x , y , x , y + 9, "#000000");
-- line(x + 1, y + 1, x + 6 , y + 6, "#000000");
-- line(x , y + 11, x + 7 , y + 7, "#000000");
end;
function hitbox(b1x1, b1y1, b1x2, b1y2, b2x1, b2y1, b2x2, b2y2, con, coff)
if con == nil then
con = "#dd0000";
end;
if coff == nil then
coff = "#00ff00"
end;
boxes = {
{
x = {b1x1, b1x2},
y = {b1y1, b1y2},
},
{
x = {b2x1, b2x2},
y = {b2y1, b2y2},
},
};
hit = false;
for xc = 1, 2 do
for yc = 1, 2 do
if (boxes[1]['x'][xc] >= boxes[2]['x'][1]) and
(boxes[1]['y'][yc] >= boxes[2]['y'][1]) and
(boxes[1]['x'][xc] <= boxes[2]['x'][2]) and
(boxes[1]['y'][yc] <= boxes[2]['y'][2]) then
hit = true;
end;
end;
end;
if hit == true then
box(b2x1, b2y1, b2x2, b2y2, con);
return true;
else
box(b2x1, b2y1, b2x2, b2y2, coff);
return false;
end;
return true;
end;
function smbpx2ram(px, py)
py = math.floor(py) - 0x20;
px = math.floor(px);
-- text(90, 16, string.format("PX[%4d] PY[%4d]", px, py));
if px < 0 or px > 400 or py < 0x00 or py > (240 - 0x20) then
return false;
end;
oy = math.floor(py / 0x10);
ox = math.fmod(math.floor((px + smbdata['screenpos']) / 0x10), 0x20);
-- text(90, 16, string.format("CX[%4X] CY[%4X]", ox, oy));
offset = 0x500 + math.fmod(oy * 0x10 + math.floor(ox / 0x10) * 0xC0 + math.fmod(ox, 0xD0), 0x1A0);
return offset;
end;
function smbram2px(offset)
offset = offset - 0x500;
if offset < 0 or offset >= 0x1A0 then
return false;
end;
px = (math.fmod(offset, 0x10) + math.floor(offset / 0xD0) * 0x10) * 0x10;
px = px - math.fmod(smbdata['screenpos'], 0x200);
-- text(8, 8, string.format("PX[%4d] OF[%4X]", px, offset));
if px < 0 then
px = px + 0x200;
end;
py = math.floor(math.fmod(offset, 0xD0) / 0x10);
returnval = {x = px, y = py};
return returnval;
end;
function smbmoveenemy(n, x, y, ax, ay)
x1 = math.fmod(x, 0x100);
x2 = math.floor(x / 0x100);
y1 = math.fmod(y, 0x100);
y2 = math.floor(y / 0x100);
memory.writebyte(0x006D + n, x2);
memory.writebyte(0x0086 + n, x1);
memory.writebyte(0x00B5 + n, y2);
memory.writebyte(0x00CE + n, y1);
memory.writebyte(0x0057 + n, ax);
memory.writebyte(0x009F + n, ay);
end;
smbdata = {screenpos = 0};
mode = 1;
last = {};
inpt = {};
enemyhold = {};
while (true) do
smbdata['screenposold'] = smbdata['screenpos'];
smbdata['screenpos'] = memory.readbyte(0x071a) * 0x100 + memory.readbyte(0x071c);
smbdata['screenposchg'] = smbdata['screenpos'] - smbdata['screenposold'];
smbdata['rendercol'] = memory.readbyte(0x06A0);
if smbdata['screenposchg'] < 0 then
smbdata['screenposchg'] = 0;
end;
timer = timer + 1;
last = table.clone(inpt);
inpt = input.get();
c = "#bbbbbb";
if inpt['leftclick']then
c = "#dd0000";
end;
-- line(0, inpt['y'], 255, inpt['y'], c);
-- line(inpt['x'], 0, inpt['x'], 244, c);
-- text(inpt['x'] - 10, 8, string.format("%3d", inpt['x']));
-- text(0, inpt['y'] - 5, string.format("%3d", inpt['y']));
i = 2;
for k,v in pairs(inpt) do
-- text(8, 8 * i, string.format("%s > %s", k, tostring(v)));
i = i + 1;
end;
c = "#ffffff";
if math.fmod(timer, 4) < 2 then
c = "#cccccc";
end;
if mode == 0 then
c1 = c;
c2 = c;
c3 = "#ffffff";
c4 = "#0000ff";
else
c1 = "#ffffff";
c2 = "#0000ff";
c3 = c;
c4 = c;
end;
text(72, 13, "Tiles");
text(99, 13, "Enemies");
box( 73, 14, 94, 22, "#000000");
box( 100, 14, 135, 22, "#000000");
if hitbox(inpt['x'], inpt['y'], inpt['x'], inpt['y'], 72, 13, 95, 23, c1, c2) and inpt['leftclick'] then
mode = 0;
end;
if hitbox(inpt['x'], inpt['y'], inpt['x'], inpt['y'], 99, 13, 136, 23, c3, c4) and inpt['leftclick'] then
mode = 1;
end;
if mode == 0 then
ramval = smbpx2ram(inpt['x'], inpt['y']);
if ramval then
ret = smbram2px(ramval);
c = "#ffffff";
if math.fmod(timer, 4) < 2 then
c = "#cccccc";
end;
if ret then
tx1 = math.max(0, ret['x'] - 1);
tx2 = math.min(0xFF, ret['x'] + 0x10);
ty1 = math.max(ret['y'] * 0x10 + 0x1F, 0);
ty2 = math.min(244, ret['y'] * 0x10 + 0x30);
box(tx1, ty1, tx2, ty2, c);
end;
textx = inpt['x'] + 10;
texty = inpt['y'] - 4;
if textx > 229 then
textx = textx - 42;
end;
texty = math.min(214, texty);
text(textx, texty, string.format("%04X", ramval));
text(textx, texty + 8, string.format(" %02X ", memory.readbyte(ramval)));
end;
else
for i=1,6 do
if (memory.readbyte(0x000E+i) ~= 0) then --and memory.readbyte(0x04AC+(i*4)) ~= 0xFF) and (memory.readbyte(0x0015 + i) ~= 0x30 and memory.readbyte(0x0015 + i) ~= 0x31) then
if not enemyhold[i] or not inpt['leftclick'] then
enemyhold[i] = nil;
-- text(8, 50 + i * 8, "-");
elseif enemyhold[i] then
-- text(8, 50 + i * 8, string.format("HOLD %04X %04X", smbdata['screenpos'] + inpt['x'] - enemyhold[i]['x'], inpt['y'] + 0x100 - enemyhold[i]['y']));
smbmoveenemy(i, smbdata['screenpos'] + inpt['x'] - enemyhold[i]['x'], inpt['y'] + 0x100 - enemyhold[i]['y'], (inpt['x'] - last['x']) * 8, inpt['y'] - last['y']);
end;
e2x1 = memory.readbyte(0x04AC+(i*4));
e2y1 = memory.readbyte(0x04AC+(i*4)+1);
e2x2 = memory.readbyte(0x04AC+(i*4)+2);
e2y2 = memory.readbyte(0x04AC+(i*4)+3);
-- text(e2x1 - 5, e2y1 - 13, string.format("%02X", memory.readbyte(0x001E + i)));
enemyxpos = memory.readbytesigned(0x006D + i) * 0x0100 + memory.readbyte(0x0086 + i);
enemyypos = memory.readbytesigned(0x00B5 + i) * 0x100 + memory.readbyte(0x00CE + i);
enemyxacc = memory.readbytesigned(0x0057 + i);
enemyyacc = memory.readbytesigned(0x009f + i);
enemyxposa = enemyxpos - smbdata['screenpos'];
enemyyposa = enemyypos - 0x100;
enemyyposa2 = math.fmod(enemyyposa + 0x10000, 0x100);
line(enemyxposa, enemyyposa2, enemyxposa + 16, enemyyposa2, "#ffffff");
dead = "";
if enemyyposa <= -72 then
dead = "DEAD";
end;
text(8, 24 + 8 * i, string.format("E%X - %04d %04d %04d %04d %3d %3d %s", i, enemyxpos, enemyypos, enemyxposa, enemyyposa, enemyxacc, enemyyacc, dead));
if hitbox(inpt['x'], inpt['y'], inpt['x'], inpt['y'], e2x1, e2y1, e2x2, e2y2) then
-- if hitbox(inpt['x'], inpt['y'], inpt['x'], inpt['y'], enemyxposa, enemyyposa, enemyxposa + 0xF, enemyyposa + 0x17) then
-- text(e2x1 - 5, e2y1 - 13, string.format("#%d %02X", i, memory.readbyte(0x0015 + i)));
if inpt['leftclick'] then
if not enemyhold[i] then
enemyhold[i] = { x = inpt['x'] - enemyxposa, y = inpt['y'] - enemyyposa };
end;
-- memory.writebyte(0x001F + i, 0xFF);
-- memory.writebyte(0x04AC + i, 0xFF);
-- memory.writebyte(0x000E + i, 0x00);
end;
end;
else
enemyhold[i] = nil;
end;
end;
end;
--[[
zap = zapper.read();
box(zap['x'] - 5, zap['y'] - 5, zap['x'] + 5, zap['y'] + 5, "#ffffff");
if zap['click'] == 1 then
box(zap['x'] - 7, zap['y'] - 7, zap['x'] + 7, zap['y'] + 7, "#ff0000");
end;
line(zap['x'] - 0, zap['y'] - 9, zap['x'] + 0, zap['y'] + 9, "#ffffff");
line(zap['x'] - 9, zap['y'] - 0, zap['x'] + 9, zap['y'] + 0, "#ffffff");
]]
drawmouse(inpt['x'], inpt['y'], inpt['leftclick']);
FCEU.frameadvance();
end

View File

@ -1,69 +0,0 @@
--quick and dirty script that shows zapper position and fire button presses
Z_LSPAN = 20 --life span (in frames) of white box
Z_LSPAN_CLICK = 30 --life span of red box
Z_MAX = 60 --maximum amount of boxes on screen
zbuf = {}
zindex = 0
timer = 0
function zapper_add_coord(x,y,click)
zbuf[zindex] = {t=timer,x=x,y=y,click=click}
zindex = zindex + 1
if(zindex>Z_MAX) then
zindex = 0
end
end
function box(x1,y1,x2,y2,color1,color2)
if(x1>=0 and y1>=0 and x2<=255 and y2<=255) then
gui.drawbox(x1, y1, x2, y2, color1, color2)
end
end
lastclick = zapper.read().click
lastx=zapper.read().x
lasty=zapper.read().y
while(true) do
x = zapper.read().x
y = zapper.read().y
click = zapper.read().click
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));
if(click==1 and click~=lastclick) then
zapper_add_coord(x,y,1)
elseif(x~=lastx or y~=lasty) then
zapper_add_coord(x,y,0)
end
lastclick=click
lastx=x
lasty=y
box(x-3, y-3, x+3, y+3, "white", 0)
for i=0,100 do
if(zbuf[i]) then
ltime = timer-zbuf[i].t
if(zbuf[i].click==0) then
if(ltime<Z_LSPAN) then
boxsize = (zbuf[i].t-timer+Z_LSPAN) / (Z_LSPAN/3)
c = "white"
box(zbuf[i].x-boxsize, zbuf[i].y-boxsize, zbuf[i].x+boxsize, zbuf[i].y+boxsize, c, 0)
end
elseif(zbuf[i].click==1) then
if(ltime<Z_LSPAN_CLICK) then
boxsize = (timer-zbuf[i].t) / (Z_LSPAN_CLICK/10)
c = "red"
box(zbuf[i].x-boxsize, zbuf[i].y-boxsize, zbuf[i].x+boxsize, zbuf[i].y+boxsize, c, 0)
end
end
end
end
FCEU.frameadvance();
timer = timer + 1
end