/usr/share/fceux/luaScripts/Excitingbike.lua is in fceux 2.2.2+dfsg0-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | --Exicitebike
--Written by XKeeper
--Shows various stats including a RAM map & speed
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;
function gameloop()
end;
gui.register(gameloop);
barcolors = {};
barcolors[0] = "#000000";
barcolors[1] = "#880000";
barcolors[2] = "#ff0000";
barcolors[3] = "#eeee00";
barcolors[4] = "#00ff00";
barcolors[5] = "#00ffff";
barcolors[6] = "#0000ff";
barcolors[7] = "#ff00ff";
barcolors[8] = "#ffffff";
barcolors[9] = "#123456";
lastvalue = {};
justblinked = {};
lastzero = {};
timer = 0;
speed = 0;
while (true) do
timer = timer + 1;
lastvalue['speed'] = speed;
speed = memory.readbyte(0x0094) * 0x100 + memory.readbyte(0x0090);
positionx = memory.readbyte(0x0050) * 0x100 + memory.readbyte(0x0394);
timerspeed = 3 - memory.readbyte(0x004c);
timerslant = math.max(0, memory.readbyte(0x0026) - 1);
if memory.readbyte(0x0303) ~= 0x8E then
text(255, 181, "Didn't advance this frame");
end;
speedadj1 = math.fmod(speed, 0x100);
speedadj2 = math.fmod(math.floor(speed / 0x100), #barcolors + 1);
speedadj3 = math.fmod(speedadj2 + 1, #barcolors + 1);
lifebar( 61, 11, 100, 4, speedadj1, 0x100, barcolors[speedadj3], barcolors[speedadj2], "#000000", "#ffffff");
text(198, 9, string.format("Speed %2d", timerspeed));
text(196, 17, string.format(" Slant %2d", timerslant));
box( 186, 10, 198, 18, "#000000");
box( 186, 18, 198, 26, "#000000");
if timerspeed == 0 then
filledbox(187, 11, 197, 17, "#00ff00");
if memory.readbyte(0x00B0) ~= 0 then
temp = "->";
else
temp = "(B)";
end;
text( 0, 50, string.format("Hold %s to maintain speed", temp));
else
filledbox(187, 11, 197, 17, "#880000");
end;
if timerslant <= 1 then
filledbox(187, 19, 197, 25, "#00ff00");
text( 0, 58, string.format("Use < + > to modify angle"));
else
filledbox(187, 19, 197, 25, "#880000");
end;
text( 0, 4 + 6, string.format("Speed: %4X", speed));
text( 1, 4 + 14, string.format("S.Chg: %4d", speed - lastvalue['speed']));
value = memory.readbyte(0x0064);
lifebar( 1, 1, 240, 6, value, 0xFF, "#ffffff", "#111144", false, "#000000");
tp = math.floor(value / 255 * 240) + 4;
text(tp, 1, string.format("%02X", value));
drawerpos = memory.readbyte(0x00e8);
screenpos = memory.readbyte(0x00eb);
for x = 0, 0x3F do
for y = 0, 5 do
offset = y * 0x40 + x + 0x400;
value = memory.readbyte(offset);
color = string.format("#%02x%02x%02x", value, value, value);
x = math.fmod(x - screenpos, 0x40);
while (x < 0) do
x = x + 0x40;
end;
box(x * 3 + 8, y * 3 + 28, x * 3 + 9, y * 3 + 30, color);
box(x * 3 + 9, y * 3 + 28, x * 3 +10, y * 3 + 30, color);
-- pixel(x * 3 + 9, y * 3 + 28, color);
end;
end;
drawerpos = drawerpos - screenpos;
while (drawerpos < 0) do
drawerpos = drawerpos + 0x40;
end;
box(math.fmod(drawerpos, 0x40) * 3 + 7, 27, math.fmod(drawerpos, 0x40) * 3 + 11, 5 * 3 + 31, "#dd0000");
-- box(math.fmod(screenpos, 0x40) * 3 + 7, 25, math.fmod(screenpos, 0x40) * 3 + 11, 5 * 3 + 31, "#00ff00");
box(math.fmod(0, 0x40) * 3 + 7, 27, math.fmod(0, 0x40) * 3 + 11, 5 * 3 + 31, "#00ff00");
for i = 0, 5 do
offset = 0x00e8 + i;
if not lastzero[offset] then
lastzero[offset] = {};
end;
value = memory.readbyte(offset);
if lastvalue[offset] and lastvalue[offset] ~= value then
if not justblinked[offset] then
color = "#ffffff";
else
color = "#dd0000";
end;
justblinked[offset] = true;
else
color = "#dd0000";
justblinked[offset] = false;
end;
lifebar( 3, 190 + i * 8, 240, 6, value, 240, color, "#111144", false, "#000000");
tp = math.floor(value / 240 * 240) + 4;
text(tp, 190 + i * 8, string.format("%02X", value));
if lastzero[offset]['time'] then
text(165, 190 + i * 8, string.format("%7sa %4df", string.format("%.2f", (lastzero[offset]['total'] / lastzero[offset]['samples'])), lastzero[offset]['time']));
end;
if value == 0 and not lastzero[offset]['uhoh'] then
if lastzero[offset]['fr'] then
lastzero[offset]['time'] = timer - lastzero[offset]['fr'];
if lastzero[offset]['total'] then
lastzero[offset]['total'] = lastzero[offset]['total'] + lastzero[offset]['time'];
lastzero[offset]['samples'] = lastzero[offset]['samples'] + 1;
else
lastzero[offset]['total'] = lastzero[offset]['time'];
lastzero[offset]['samples'] = 1;
end;
end;
lastzero[offset]['fr'] = timer;
lastzero[offset]['uhoh'] = true;
elseif value ~= 0 then
lastzero[offset]['uhoh'] = false;
end;
lastvalue[offset] = value;
end;
--[[
startoffset = 0x5E0;
s = 0x120;
xs = 0x40;
ys = math.floor(s / xs);
for x = 0, xs - 1 do
for y = 0, ys - 1 do
offset = y * xs + x + startoffset;
value = memory.readbyte(offset);
if value == 0x40 then
color = "clear";
else
value = math.fmod(value * 0x10, 0x100);
color = string.format("#%02x%02x%02x", value, value, value);
end;
box(x * 3 + 8, y * 3 + 64, x * 3 + 10, y * 3 + 66, color);
pixel(x * 3 + 9, y * 3 + 65, color);
end;
end;
]]
FCEU.frameadvance();
end;
|