Unburied lua scripts and put them in a folder in output
This commit is contained in:
parent
38c4130b4b
commit
fd0753199e
|
@ -0,0 +1,60 @@
|
||||||
|
|
||||||
|
-- SMB1 script by 4matsy. Yay.
|
||||||
|
-- 2008, September 11th.
|
||||||
|
|
||||||
|
require("shapedefs");
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
function line(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.drawline(x1,y1,x2,y2,color);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
while (true) do
|
||||||
|
|
||||||
|
-- print player's lives...I always thought this was a major omission of the status bar :p
|
||||||
|
text(63,13,"x"..memory.readbyte(0x075a)+1);
|
||||||
|
|
||||||
|
-- check the enemy identifier buffer for presence of t3h b0ws3r (id #2d). if found, show his hp.
|
||||||
|
for i=0,5 do
|
||||||
|
if memory.readbyte((0x0016)+i) == 0x2d then -- aha, found you. YOU CANNOT HIDE FROM MY MAD SCRIPTZ0RING SKILLZ BWAHAHA
|
||||||
|
local bowsermaxhp = memory.readbyte(0xc56c); -- bowser's starting hp
|
||||||
|
local bowsercurhp = memory.readbyte(0x0483); -- bowser's current hp
|
||||||
|
local meterx = 104; -- x-origin of the meter
|
||||||
|
local metery = 228; -- y-origin of the meter
|
||||||
|
local spacingx = 8; -- how much x-space between each shape?
|
||||||
|
local spacingy = 0; -- how much y-space between each shape?
|
||||||
|
text((meterx-2),(metery-11),"Bowser:");
|
||||||
|
for a=0,bowsermaxhp-1 do
|
||||||
|
drawshape((meterx+(spacingx*a)+0),(metery+(spacingy*a)+1),"heart_7x7","#000000");
|
||||||
|
drawshape((meterx+(spacingx*a)+1),(metery+(spacingy*a)+0),"heart_7x7","#000000");
|
||||||
|
drawshape((meterx+(spacingx*a)+1),(metery+(spacingy*a)+1),"heart_7x7","#000000");
|
||||||
|
drawshape((meterx+(spacingx*a)+0),(metery+(spacingy*a)+0),"heart_7x7","#ffffff");
|
||||||
|
if a < bowsercurhp then
|
||||||
|
drawshape((meterx+(spacingx*a)+1),(metery+(spacingy*a)+1),"heart_5x5","#ff0000");
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
FCEU.frameadvance();
|
||||||
|
end;
|
|
@ -0,0 +1,15 @@
|
||||||
|
while (true) do
|
||||||
|
|
||||||
|
key1 = input.get();
|
||||||
|
|
||||||
|
|
||||||
|
if (key1.A) then
|
||||||
|
gui.text(10,10,"Success!");
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
FCEU.frameadvance();
|
||||||
|
|
||||||
|
end;
|
|
@ -0,0 +1,173 @@
|
||||||
|
|
||||||
|
x_func_version = 5;
|
||||||
|
|
||||||
|
--[[
|
||||||
|
Minor version history:
|
||||||
|
|
||||||
|
v 5 -----------
|
||||||
|
- Added Bisqwit's 'clone table' function.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
]]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- Draws a line from x1,y1 to x2,y2 using color
|
||||||
|
|
||||||
|
function line(x1,y1,x2,y2,color)
|
||||||
|
if (x1 >= 0 and x1 <= 255 and x2 >= 0 and x2 <= 255 and y1 >= 0 and y1 <= 244 and y2 >= 0 and y2 <= 244) then
|
||||||
|
local success = pcall(function() gui.drawline(x1,y1,x2,y2,color) end);
|
||||||
|
if not success then
|
||||||
|
text(60, 224, "ERROR: ".. x1 ..",".. y1 .." ".. x2 ..",".. y2);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
-- Puts text on-screen (duh)
|
||||||
|
function text(x,y,str)
|
||||||
|
if str == nil then
|
||||||
|
str = "nil";
|
||||||
|
end;
|
||||||
|
if (x >= 0 and x <= 255 and y >= 0 and y <= 240) then
|
||||||
|
gui.text(x,y,str);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
-- Sets the pixel at x, y to color
|
||||||
|
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;
|
||||||
|
|
||||||
|
|
||||||
|
-- Draws a rectangle from x1,y1 to x2, y2
|
||||||
|
function box(x1,y1,x2,y2,color)
|
||||||
|
if (x1 >= 0 and x1 <= 255 and x2 >= 0 and x2 <= 255 and y1 >= 0 and y1 <= 244 and y2 >= 0 and y2 <= 244) then
|
||||||
|
gui.drawbox(x1,y1,x2,y2,color);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
-- Draws a filled box from x1, y1 to x2, y2 (warning: can be slow if drawing large boxes)
|
||||||
|
function filledbox(x1,y1,x2,y2,color)
|
||||||
|
for i = 0, math.abs(y1 - y2) do
|
||||||
|
line(x1,y1 + i,x2,y1 + i,color);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- Draws a life-bar.
|
||||||
|
-- x, y: position of top-right
|
||||||
|
-- sx, sy: width and height of ACTUAL BAR (0 is the smallest height (1px))
|
||||||
|
-- a1, a2: Amounts (a1/a2*100 = % of bar filled)
|
||||||
|
-- oncolor, offcolor: "bar", "background"
|
||||||
|
-- noborder: set to "true" if you just want a black outline without the white
|
||||||
|
|
||||||
|
function lifebar(x, y, sx, sy, a1, a2, oncolor, offcolor, outerborder, innerborder)
|
||||||
|
-- this function will have the effect of drawing an HP bar
|
||||||
|
-- keep in mind xs and ys are 2px larger to account for borders
|
||||||
|
|
||||||
|
x1 = x;
|
||||||
|
x2 = x + sx + 4;
|
||||||
|
y1 = y;
|
||||||
|
y2 = y + sy + 4;
|
||||||
|
w = math.floor(a1 / math.max(1, a1, a2) * sx);
|
||||||
|
if not a2 then w = 0 end;
|
||||||
|
|
||||||
|
outer = outerborder;
|
||||||
|
inner = innerborder;
|
||||||
|
|
||||||
|
if (outer == true or outer == false) and (inner == nil) then
|
||||||
|
-- legacy
|
||||||
|
outer = nil;
|
||||||
|
inner = "#000000";
|
||||||
|
|
||||||
|
elseif outer == nil and inner == nil then
|
||||||
|
outer = "#000000";
|
||||||
|
inner = "#ffffff";
|
||||||
|
|
||||||
|
elseif inner == nil then
|
||||||
|
inner = "#ffffff";
|
||||||
|
end;
|
||||||
|
|
||||||
|
if (inner) then
|
||||||
|
box(x1 + 1, y1 + 1, x2 - 1, y2 - 1, inner);
|
||||||
|
end;
|
||||||
|
if (outer) then
|
||||||
|
box(x1 , y1 , x2 , y2 , outer);
|
||||||
|
end;
|
||||||
|
|
||||||
|
if (w < sx) then
|
||||||
|
filledbox(x1 + w + 2, y1 + 2, x2 - 2, y2 - 2, offcolor);
|
||||||
|
end;
|
||||||
|
|
||||||
|
if (w > 0) then
|
||||||
|
filledbox(x1 + 2, y1 + 2, x1 + 2 + w, y2 - 2, oncolor);
|
||||||
|
end;
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function graph(x, y, sx, sy, minx, miny, maxx, maxy, xval, yval, color, border, filled)
|
||||||
|
|
||||||
|
|
||||||
|
if (filled ~= nil) then
|
||||||
|
filledbox(x + 1, y + 1, x+sx, y+sy, "#000000");
|
||||||
|
end;
|
||||||
|
if (border ~= nil) then
|
||||||
|
box(x, y, x+sx+1, y+sy+1, color);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
xp = (xval - minx) / (maxx - minx) * sx;
|
||||||
|
yp = (yval - miny) / (maxy - miny) * sy;
|
||||||
|
|
||||||
|
line(x + 1 , yp + y + 1, x + sx + 1, yp + y + 1, color);
|
||||||
|
line(xp + x + 1, y + 1 , xp + x + 1, y + sy + 1, color);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
-- Bisqwit's clone table feature.
|
||||||
|
table.clone = function(table)
|
||||||
|
local res = {}
|
||||||
|
for k,v in pairs(table)do
|
||||||
|
res[k]=v
|
||||||
|
end
|
||||||
|
return res
|
||||||
|
end
|
||||||
|
|
||||||
|
function x_requires(required)
|
||||||
|
-- Sanity check. If they require a newer version, let them know.
|
||||||
|
timer = 1;
|
||||||
|
if x_func_version < required then
|
||||||
|
|
||||||
|
while (true) do
|
||||||
|
timer = timer + 1;
|
||||||
|
|
||||||
|
for i = 0, 32 do
|
||||||
|
box( 6, 28 + i, 250, 92 - i, "#000000");
|
||||||
|
end;
|
||||||
|
|
||||||
|
text( 10, 32, string.format("This Lua script requires version %02d or greater.", required));
|
||||||
|
text( 43, 42, string.format("Your x_functions.lua is version %02d.", x_func_version));
|
||||||
|
text( 29, 58, "Please check for an updated version at");
|
||||||
|
text( 14, 69, "http://xkeeper.shacknet.nu/");
|
||||||
|
text(114, 78, "emu/nes/lua/x_functions.lua");
|
||||||
|
|
||||||
|
warningboxcolor = string.format("%02X", math.floor(math.abs(30 - math.fmod(timer, 60)) / 30 * 0xFF));
|
||||||
|
box(7, 29, 249, 91, "#ff" .. warningboxcolor .. warningboxcolor);
|
||||||
|
|
||||||
|
FCEU.frameadvance();
|
||||||
|
end;
|
||||||
|
|
||||||
|
end;
|
||||||
|
end;
|
|
@ -0,0 +1,41 @@
|
||||||
|
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
|
|
@ -0,0 +1,337 @@
|
||||||
|
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
|
|
@ -0,0 +1,69 @@
|
||||||
|
--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
|
||||||
|
|
Loading…
Reference in New Issue