update gargoyles script (with a 2yo version)

This commit is contained in:
feos 2019-06-14 21:52:41 +03:00
parent f6bd34c7ef
commit dfd80d23fc
1 changed files with 521 additions and 447 deletions

View File

@ -1,448 +1,522 @@
-- Gargoyles, Genesis (BizHawk) -- Gargoyles, Genesis (BizHawk)
-- feos, 2015-2016 -- feos, 2015-2017
--== Shortcuts ==-- --== Shortcuts ==--
rb = memory.read_u8 local rb = memory.read_u8
rw = memory.read_u16_be local rw = memory.read_u16_be
rws = memory.read_s16_be local rws = memory.read_s16_be
r24 = memory.read_u24_be local r24 = memory.read_u24_be
rl = memory.read_u32_be local rl = memory.read_u32_be
box = gui.drawBox local box = gui.drawBox
text = gui.pixelText local text = gui.text
line = gui.drawLine local ptext = gui.pixelText
AND = bit.band local line = gui.drawLine
SHIFT = bit.rshift local AND = bit.band
local SHIFT = bit.rshift
--== RAM addresses ==--
levnum = 0xff00ba --== RAM addresses ==--
LevelFlr = 0xff00c0 local levnum = 0xff00ba
LevelCon = 0xff00c4 local LevelFlr = 0xff00c0
mapline_tab = 0xff0244 local LevelCon = 0xff00c4
GlobalBase = 0xff1c76 local mapline_tab = 0xff0244
GolBase = 0xff2c76 local GlobalBase = 0xff1c76
MapA_Buff = 0xff4af0 local GolBase = 0xff2c76
local MapA_Buff = 0xff4af0
--== Camera Hack ==--
camhack = false --== Camera Hack ==--
div = 1 -- scale local camhack = false
size = 16/div -- block size local div = 1 -- scale
local size = 16/div -- block size
--== Block cache ==--
col = 0 -- block color --== Block cache ==--
opout = 0x33000000 -- outer opacity local col = 0 -- block color
opin = 0x66000000 -- inner opacity local opout = 0x33000000 -- outer opacity
op = 0xff000000 local opin = 0x66000000 -- inner opacity
cache = {} local op = 0xff000000
local cache = {}
--== Other stuff ==--
XposLast = 0 --== Other stuff ==--
YposLast = 0 local MsgCutoff = 20
room = 0 local MsgTime = 1
workinglast = 0 local MsgStep = 14
lagcount = emu.lagcount() local MsgOffs = 2
gui.defaultPixelFont("fceux") local MsgTable = {}
local XposLast = 0
function main() local YposLast = 0
rnd1 = rl (0xff001c) local room = 0
rnd2 = rw (0xff0020) local workinglast = 0
working = rb (0xff0073) local wSize = client.getwindowsize()
xblocks = rw (0xff00d4) local lagcount = emu.lagcount()
mapw = rw (0xff00d4)*8 gui.defaultTextBackground(0xff000000)
maph = rw (0xff00d6)*8
Xpos = rws(0xff0106) --== Object types ==--
Ypos = rws(0xff0108) local types = {
camx = rws(0xff010c)+16 "Goliath","Orb","Health1PLR","Health2PLR","Health1NME","Health2NME","Numeral",
camy = rws(0xff010e)+16 "BigExplode","SmallExplode","GlassDebris","MetalDebris","WoodDebris",
run = rb (0xff1699) "WallDebris","SignPiece","SteamVent","BreakWall","SkyLight","BreakLight",
inv = rw (0xff16d2) "ThrowCrate","BreakEdgeLeft","BreakEdgeRight","Spark","Spark2","Sparks",
health = rws(0xff2cc6) "Sparks2","Fireball","HomingProj1","HorzProj1","VertProj1","DirProj1",
backx = camx "DirProj2","DropMine","Scratch","Icon","RaptorBot","SniperBot","SpiderBot",
backy = camy "WaspBot","Xanatos","PlasmaBot","RabidHH","MorningStar","Archer","Arrow",
Xspd = Xpos-XposLast "Valkyrie","Axe","WeaponExp","Couldron","SpittingCouldron","FireballHead",
Yspd = Ypos-YposLast "FireballTrail","BigFireballHead","BigFireballTrail","Oil","OilGenerator",
facing = AND(rb(GolBase+0x48),2) -- object flag 1 "Claw","Stump","StumpBubble","StumpFire","ClawStump","StumpFireGen","Vent",
"VentSparks","Chain","FlameLick","Floor","MutVikBody","MutVikHead",
Background() "MutVikHammer","EyeOfOdin","EyeOfOdinTrail","L1BreakWall","Catapult",
CamhackHUD() "L1BreakFloor","Gate","GateCrusher","Weight","WeightCrusher","WallFire",
Objects() "Balista","BalistaLog","PasteWall","FlameBoulder","CastlePiece",
PlayerBoxes() "MutantSpiderBot","MutSpiLegs","MutSpiHead","MutSpiHeadFlame","MutSpiProj",
HUD() "MutSpiElecV","MutSpiElecH","PlasmaBall","PlasmaBallTail","PlasmaDeadHead",
RoomTime() "VertFlame","WallFlame","FloorFlame","OPPlatform","OPLink","OPOrb",
Input() "Furnace","RobotGenerator","RockGenerator","BigRock","MediumRock",
end "SmallRock","BigCouldronGen","BigCouldron","Trough","TroughGen","Energizer",
"Demona","TrajectoryProj","WallPaste","EdgePaste","Tentacle","Infuser",
function RoomTime() "BigGuns","BigGunsProj","HighSignPole","HighSign","LowLight","L5Skylight",
local start11 = 894--767 "L5Wall","ElecGenerator","Electricity","WaspGenerator","TunnelEdge",
local start12 = 2294 "ForegroundPost","Sorcerer","LightningTop","LightningBot","MDemonaWallFire",
local start13 = 4101 "MDemonaFloorFire","EyeRooftopUp","EyeRooftopDn","EyeRaptor"
local startl4 = 6000 }
timer = emu.framecount()
local function RoomTime()
if timer < start11 then room = timer local start11 = 894--767
elseif timer < start12 then room = timer - start11 local start12 = 2294
elseif timer < start13 then room = timer - start12 local start13 = 5468 -- 4254 -- 4101
elseif timer < startl4 then room = timer - start13 local startl4 = 5506
end local startl5 = 7117
text(160,214,"room cnt: "..room, "white") local startl6 = 8412
end local startl7 = 17117
local timer = emu.framecount()
function HUD() if timer < start11 then room = timer
text(1, 0,emu.framecount(), framecol) elseif timer < start12 then room = timer - start11
text(1,20,emu.lagcount(), "red") elseif timer < start13 then room = timer - start12
text(1,30,movie.rerecordcount(),"orange") elseif timer < startl4 then room = timer - start13
elseif timer < startl5 then room = timer - startl4
if working>0 then return end elseif timer < startl6 then room = timer - startl5
if rndlast ~= rnd1 then rndcol = "red" else rndcol = "white" end elseif timer < startl7 then room = timer - startl6
end
text( 0,214,"rnd: ","yellow") text(2, 2, string.format("cx:%5d\ncy:%5d\nroom:%d", camx, camy, room), "white", "bottomright")
text( 26,214,string.format("%08X %04X",rnd1,rnd2),rndcol) end
text(277, 0,string.format(
"x: %4d\ny: %4d\ndx: %3d\ndy: %3d\nhp: %3d\nrun:%3d\ninv:%3d", local function HUD()
Xpos,Ypos,Xspd,Yspd,health,run,inv) --if working > 0 then return end
) local rndcol = "white"
end if rndlast ~= rnd1 then rndcol = "red" end
text(0, 2, string.format("RNG:%08X %04X", rnd1, rnd2), rndcol, "bottomleft")
function CamhackHUD() text(2, 0, string.format(
if working==0 then "x: %4d\ny: %4d\ndx: %3d\ndy: %3d\nhp: %3d\nrun:%3d\ninv:%3d",
-- screen edge Xpos, Ypos, Xspd, Yspd, health, run, inv),
box((backx-camx- 1)/div, "white", "topright")
(backy-camy- 1)/div, end
(backx-camx+320)/div,
(backy-camy+224)/div, local function CamhackHUD()
0xff0000ff) if working == 0 then
-- map edge -- screen edge
box( 0-camx/div+size, box((backx-camx- 1)/div,
0-camy/div+size, (backy-camy- 1)/div,
mapw/div-camx/div, (backx-camx+320)/div,
maph/div-camy/div, (backy-camy+224)/div,
0xff0000ff) 0xff0000ff, 0)
end -- map edge
box( 0-camx/div+size,
text(260,206,string.format("cHack: %s\nscale: %d",ch,div)) 0-camy/div+size,
end mapw/div-camx/div,
maph/div-camy/div,
function Background() 0xff0000ff, 0)
if working>0 then end
cache = {} if camhack or div > 1 then
return text(0, 0, string.format("div:%d", div), "white", "topleft")
end end
end
if camhack then
camx = Xpos-320/2*div local function PosToIndex(x, y)
camy = Ypos-224/2*div return math.floor(x/16)+math.floor(y/16)*xblocks
box(0,0,320,240,0,0x66000000) end
ch = "on"
else local function IndexToPos(i)
ch = "off" return { x=(i%xblocks)*16, y=math.floor(i/xblocks)*16 }
end end
local border = 0 local function InBounds(x, minimum, maximum)
local offset = 32 if x >= minimum and x <= maximum
local basex = camx+border then return true
local basey = camy+border else return false
local basei = PosToIndex(basex-offset,basey-offset) end
local boundx = 320*div-border end
local boundy = 224*div-border
local xblockstockeck = ((camx+boundx+offset)-(basex-offset))/size/div local function GetBlock(x, y)
local yblockstockeck = ((camy+boundy+offset)-(basey-offset))/size/div if working > 0 then return nil end
local final = { contour={}, block=0 }
for yblock = 0,yblockstockeck do if x > 0 and x < mapw
for xblock = 0,xblockstockeck do and y > 0 and y < maph then
local i = yblock*xblocks+xblock+basei local pixels = 0
local x = basex+xblock*size*div local x1 = x/div-camx/div
local y = basey+yblock*size*div local x2 = x1+size-1
local y1 = y/div-camy/div
if InBounds(x,basex-offset,camx+boundx+offset) then local y2 = y1+size-1
local unit = cache[i] local d4 = rw(mapline_tab+SHIFT(y, 4)*2)
local a1 = r24(LevelFlr+1)
if unit == nil or workinglast>0 then local d1 = SHIFT(rw(MapA_Buff+d4+SHIFT(x, 4)*2), 1)
if InBounds(x,basex,camx+boundx) final.block = rb(a1+d1+2)
and InBounds(y,basey,camy+boundy) d1 = rw(a1+d1)
then cache[i] = GetBlock(x,y) a1 = r24(LevelCon+1)+d1
end if rb(a1) > 0 or rb(a1+8) > 0 then
else for pixel=0, 15 do
if not InBounds(x,basex,camx+boundx) final.contour[pixel] = rb(a1+pixel)
and not InBounds(y,basey,camy+boundy) end
then cache[i] = nil else
end final.contour = nil
end end
else
if unit ~= nil then return nil
DrawBG(unit,x,y) end
end return final
elseif cache[i] ~= nil end
then cache[i] = nil
end local DrawBlock = {
end [0x80] = function(x1, y1, x2, y2) -- WALL
end col = 0x00ffffff -- white
end line(x1, y1, x1, y2, col+op) -- left
line(x2, y1, x2, y2, col+op) -- right
function DrawBG(unit, x, y) end,
local val= 0 [0x81] = function(x1, y1, x2, y2) -- CEILING
local x1 = x/div-camx/div-(camx%16)/div col = 0x00ffffff -- white
local x2 = x1+size-1 line(x1, y2, x2, y2, col+op) -- bottom
local y1 = y/div-camy/div-(camy%16)/div end,
local y2 = y1+size-1 [0x82] = function(x1, y1, x2, y2) -- CLIMB_U
col = 0x0000ffff -- cyan
if unit.contour ~= nil then line(x1, y2, x2, y2, col+op) -- bottom
box(x1,y1,x2,y2,0x5500ff00,0x5500ff00) end,
[0x83] = function(x1, y1, x2, y2) -- CLIMB_R
for pixel=0,15 do col = 0x0000ffff -- cyan
val = unit.contour[pixel] line(x1, y1, x1, y2, col+op) -- left
if val>0 then end,
gui.drawPixel( [0x84] = function(x1, y1, x2, y2) -- CLIMB_L
x1+pixel/div, col = 0x0000ffff -- cyan
y1+val/div-1/div, line(x2, y1, x2, y2, col+op) -- right
0xffffff00) end,
end [0x85] = function(x1, y1, x2, y2) -- CLIMB_LR
end col = 0x0000ffff -- cyan
end line(x1, y1, x1, y2, col+op) -- left
line(x2, y1, x2, y2, col+op) -- right
if unit.block>0 then end,
local Fn = DrawBlock[unit.block] or DrawBlockDefault [0x86] = function(x1, y1, x2, y2) -- CLIMB_R_STAND_R
Fn(x1,y1,x2,y2) col = 0x00ffffff -- white
box(x1,y1,x2,y2,col+opin,col+opout) line(x1, y1, x2, y1, col+op) -- top
end col = 0x0000ffff -- cyan
end line(x1, y1, x1, y2, col+op) -- left
end,
function GetBlock(x,y) [0x87] = function(x1, y1, x2, y2) -- CLIMB_L_STAND_L
if working>0 then return nil end col = 0x00ffffff -- white
line(x1, y1, x2, y1, col+op) -- top
local final = { contour={}, block=0 } col = 0x0000ffff -- cyan
line(x2, y1, x2, y2, col+op) -- right
if x>0 and x<mapw end,
and y>0 and y<maph then [0x88] = function(x1, y1, x2, y2) -- CLIMB_LR_STAND_LR
local pixels = 0 col = 0x00ffffff -- white
local x1 = x/div-camx/div line(x1, y1, x2, y1, col+op) -- top
local x2 = x1+size-1 col = 0x00ff00ff -- cyan
local y1 = y/div-camy/div line(x1, y1, x1, y2, col+op) -- left
local y2 = y1+size-1 col = 0x0000ffff -- cyan
local d4 = rw(mapline_tab+SHIFT(y,4)*2) line(x2, y1, x2, y2, col+op) -- right
local a1 = r24(LevelFlr+1) end,
local d1 = SHIFT(rw(MapA_Buff+d4+SHIFT(x,4)*2),1) [0x70] = function(x1, y1, x2, y2) -- GRAB_SWING
final.block = rb(a1+d1+2) col = 0x0000ff00 -- green
d1 = rw(a1+d1) box(x1, y1, x2, y2, col, col+opout)
a1 = r24(LevelCon+1)+d1 end,
[0x7f] = function(x1, y1, x2, y2) -- EXIT
if rb(a1)>0 or rb(a1+8)>0 then col = 0x00ffff00 -- yellow
for pixel=0,15 do end,
final.contour[pixel] = rb(a1+pixel) [0xd0] = function(x1, y1, x2, y2) -- SPIKES
end col = 0x00ff0000 -- red
else box(x1, y1, x2, y2, col, col+opout)
final.contour = nil end,
end [0xd1] = function(x1, y1, x2, y2) -- SPIKES
else col = 0x00ff0000 -- red
return nil box(x1, y1, x2, y2, col, col+opout)
end end
}
return final
end local function DrawBlockDefault(x1, y1, x2, y2) -- LEVEL_SPECIFIC
col = 0x00ff8800 -- orange
function PosToIndex(x,y) box(x1, y1, x2, y2, col+opin, col+opout)
return math.floor(x/16)+math.floor(y/16)*xblocks end
end
local function DrawBG(unit, x, y)
function IndexToPos(i) local val= 0
return { x=(i%xblocks)*16, y=math.floor(i/xblocks)*16 } local x1 = x/div-camx/div-(camx%16)/div
end local x2 = x1+size-1
local y1 = y/div-camy/div-(camy%16)/div
function InBounds(x,minimum,maximum) local y2 = y1+size-1
if x>=minimum and x<=maximum if unit.contour ~= nil then
then return true box(x1, y1, x2, y2, 0x5500ff00, 0x5500ff00)
else return false for pixel=0, 15 do
end val = unit.contour[pixel]
end --[ [--
if val > 0 then
DrawBlock = { gui.drawPixel(
[0x80] = function(x1,y1,x2,y2) -- WALL x1+pixel/div,
col = 0x00ffffff -- white y1+val/div-1/div,
line(x1,y1,x1,y2,col+op) -- left 0xffffff00)
line(x2,y1,x2,y2,col+op) -- right end
end, --]]--
[0x81] = function(x1,y1,x2,y2) -- CEILING end
col = 0x00ffffff -- white end
line(x1,y2,x2,y2,col+op) -- bottom if unit.block > 0 then
end, local Fn = DrawBlock[unit.block] or DrawBlockDefault
[0x82] = function(x1,y1,x2,y2) -- CLIMB_U Fn(x1, y1, x2, y2)
col = 0x0000ffff -- cyan box(x1, y1, x2, y2, col+opin, col+opout)
line(x1,y2,x2,y2,col+op) -- bottom end
end, end
[0x83] = function(x1,y1,x2,y2) -- CLIMB_R
col = 0x0000ffff -- cyan local function Background()
line(x1,y1,x1,y2,col+op) -- left if working > 0 then
end, cache = {}
[0x84] = function(x1,y1,x2,y2) -- CLIMB_L return
col = 0x0000ffff -- cyan end
line(x2,y1,x2,y2,col+op) -- right if camhack then
end, camx = Xpos-320/2*div
[0x85] = function(x1,y1,x2,y2) -- CLIMB_LR camy = Ypos-224/2*div
col = 0x0000ffff -- cyan box(0, 0, 320, 240, 0, 0x66000000)
line(x1,y1,x1,y2,col+op) -- left end
line(x2,y1,x2,y2,col+op) -- right local border = 0
end, local offset = 32
[0x86] = function(x1,y1,x2,y2) -- CLIMB_R_STAND_R local basex = camx+border
col = 0x00ffffff -- white local basey = camy+border
line(x1,y1,x2,y1,col+op) -- top local basei = PosToIndex(basex-offset, basey-offset)
col = 0x0000ffff -- cyan local boundx = 320*div-border
line(x1,y1,x1,y2,col+op) -- left local boundy = 224*div-border
end, local xblockstockeck = ((camx+boundx+offset)-(basex-offset))/size/div
[0x87] = function(x1,y1,x2,y2) -- CLIMB_L_STAND_L local yblockstockeck = ((camy+boundy+offset)-(basey-offset))/size/div
col = 0x00ffffff -- white for yblock = 0, yblockstockeck do
line(x1,y1,x2,y1,col+op) -- top for xblock = 0, xblockstockeck do
col = 0x0000ffff -- cyan local i = yblock*xblocks+xblock+basei
line(x2,y1,x2,y2,col+op) -- right local x = basex+xblock*size*div
end, local y = basey+yblock*size*div
[0x88] = function(x1,y1,x2,y2) -- CLIMB_LR_STAND_LR if InBounds(x, basex-offset, camx+boundx+offset) then
col = 0x00ffffff -- white local unit = cache[i]
line(x1,y1,x2,y1,col+op) -- top if unit == nil or workinglast > 0 then
col = 0x00ff00ff -- cyan if InBounds(x, basex, camx+boundx)
line(x1,y1,x1,y2,col+op) -- left and InBounds(y, basey, camy+boundy)
col = 0x0000ffff -- cyan then cache[i] = GetBlock(x, y)
line(x2,y1,x2,y2,col+op) -- right end
end, else
[0x70] = function(x1,y1,x2,y2) -- GRAB_SWING if not InBounds(x, basex, camx+boundx)
col = 0x0000ff00 -- green and not InBounds(y, basey, camy+boundy)
box(x1,y1,x2,y2,col,col+opout) then cache[i] = nil
end, end
[0x7f] = function(x1,y1,x2,y2) -- EXIT end
col = 0x00ffff00 -- yellow if unit ~= nil then
end, DrawBG(unit, x, y)
[0xd0] = function(x1,y1,x2,y2) -- SPIKES end
col = 0x00ff0000 -- red elseif cache[i] ~= nil
box(x1,y1,x2,y2,col,col+opout) then cache[i] = nil
end, end
[0xd1] = function(x1,y1,x2,y2) -- SPIKES end
col = 0x00ff0000 -- red end
box(x1,y1,x2,y2,col,col+opout) CamhackHUD()
end end
}
local function Clamp(v, vmin, vmax)
function DrawBlockDefault(x1,y1,x2,y2)-- LEVEL_SPECIFIC if v < vmin then v = vmin end
col = 0x00ff8800 -- orange if v > vmax then v = vmax end
box(x1,y1,x2,y2,col+opin,col+opout) return v
end end
function Objects() local function Objects()
if working>0 then return end if working > 0 then return end
for i=0, 63 do
for i=0,63 do local base = GlobalBase+i*128
local base = GlobalBase+i*128 local flag2 = AND(rb(base+0x49), 0x10) -- active
local flag2 = AND(rb(base+0x49),0x10) -- active if flag2 == 0x10 then
local xpos = rw (base+0x00)
if flag2==0x10 then local ypos = rw (base+0x02)
local xpos = rw (base+0x00) local state = rw (base+0x0c)
local ypos = rw (base+0x02) local dmg = rb (base+0x10)
local dmg = rb (base+0x10) local id = rw (base+0x40)
local type = rw (base+0x40) local hp = rw (base+0x50)
local hp = rw (base+0x50) local cRAM = r24(base+0x75) -- pointer to 4 collision boxes per object
local cRAM = r24(base+0x75) -- pointer to 4 collision boxes per object local xscr = (xpos-camx)/div
local col = 0 -- collision color local yscr = (ypos-camy)/div
local xscr = (xpos-camx)/div local num = id/6
local yscr = (ypos-camy)/div local name = types[num]
local col = 0 -- collision color
for boxx=0,4 do for boxx=0, 4 do
local x1 = (rws(cRAM+boxx*8+0)-camx)/div local x0 = rw (cRAM+boxx*8)
local y1 = (rws(cRAM+boxx*8+2)-camy)/div local x1 = (rws(cRAM+boxx*8+0)-camx)/div
local x2 = (rws(cRAM+boxx*8+4)-camx)/div local y1 = (rws(cRAM+boxx*8+2)-camy)/div
local y2 = (rws(cRAM+boxx*8+6)-camy)/div local x2 = (rws(cRAM+boxx*8+4)-camx)/div
local y2 = (rws(cRAM+boxx*8+6)-camy)/div
if boxx==0 then if boxx == 0 then
col = 0xff00ff00 -- body col = 0xff00ff00 -- body
if type==282 or type==258 then hp = 1 end -- archer hp doesn't matter -- archer hp doesn't matter
if hp>0 and type>0 then if id == 282 or id == 258 then hp = 1 end
text(x1+2,y1+1,string.format("%d",hp),col,0x88000000,"gens") if hp > 0 and id > 0 and x0 ~= 0x8888 then
end local xx = Clamp(xscr, 0, 318-string.len(name)*4)
elseif boxx==1 then local yy = Clamp(yscr, 0, 214)
col = 0xffffff00 -- floor ptext(xx, yy+2, string.format("%d", hp), col)
elseif boxx==2 then end
if dmg>0 elseif boxx == 1 then
then col = 0xffff0000 -- projectile col = 0xffffff00 -- floor
else col = 0xff8800ff -- item elseif boxx == 2 then
end if dmg > 0
if dmg>0 then then col = 0xffff0000 -- projectile
text(x1+2,y2+1,string.format("%d",dmg),col,0x88000000,"gens") else col = 0xff8800ff -- item
end end
else if dmg > 0 then
col = 0xffffffff -- other text(x1*wSize+2, y2*wSize+1,
end string.format("%d", dmg), col, 0x88000000)
end
if x1~=0x8888 and x2<320 and x1>0 and y2<224 and y1>0 then else
box(x1,y1,x2,y2,col) col = 0xffffffff -- other
end end
end if x1 ~= 0x8888
end and x1 <= 320 and x2 >= 0
end and y1 <= 224 and y2 >= 0 then
end box(x1, y1, x2, y2, col, 0)
end
function PlayerBoxes() end
if working>0 then return end end
end
local xx = (Xpos-camx)/div end
local yy = (Ypos-camy)/div
local col = 0xff00ffff local function PostRndRoll()
local swcol = col -- usual detection for i = 1,#MsgTable do
if MsgTable[i] and MsgTable[i].index == i then
if Yspd>0 then -- gimme swings to grab! local base = MsgTable[i].base
swcol = 0xff00ff00 local xpos = rw(base+0x00)
elseif Yspd==0 then -- can tell that too local ypos = rw(base+0x02)
swcol = 0xffffffff local id = rw(base+0x40)
end local x = (xpos-camx)/div
local y = (ypos-camy)/div
if facing==2 then local num = id/6
box(xx-0xf /div-2,yy-0x2c/div-1,xx-0xf /div+0,yy-0x2c/div+1,swcol) -- lefttop local ymsg = 0
else local yoffs = math.floor((i-1)/MsgCutoff)*14
box(xx+0xf /div-1,yy-0x2c/div-1,xx+0xf /div+1,yy-0x2c/div+1,swcol) -- rightttop local name = types[num]
end local color = 0xffffff00
box(xx -1,yy-0x2c/div-1,xx +1,yy-0x2c/div+1,col) -- top if base == GolBase then
box(xx-0xf /div-2,yy-0x1f/div-1,xx-0xf /div+0,yy-0x1f/div+1,col) -- left name = "Goliath"
box(xx+0x10/div-1,yy-0x1f/div-1,xx+0x10/div+1,yy-0x1f/div+1,col) -- right elseif not name then
-- box(xx -1,yy-0x1f/div-1,xx +1,yy-0x1f/div+1,col) -- center name = string.format("%X", base)
box(xx -1,yy-0x0f/div-1,xx +1,yy-0x0f/div+1,col) -- bottom color = 0xff00ffff
box(xx -1,yy -1,xx +1,yy +1,0xffffff00) -- feet end
-- box(xx -1,yy+0x10/div-1,xx +1,yy+0x10/div+1,col) -- ground if y < 224/2 then
end yoffs = -yoffs
ymsg = 210
function Input() end
local i,u,d,l,r,a,b,c,s
x = Clamp(x, 2, 320-string.len(name)*4)
if movie.isloaded() then y = Clamp(y, 20, 214)
i = movie.getinput(emu.framecount()-1)
else line ((i-1)%MsgCutoff*MsgStep+3 +MsgOffs, ymsg+yoffs+4, x, y, color-0x88000000)
i = joypad.getimmediate() ptext((i-1)%MsgCutoff*MsgStep*wSize+MsgOffs, ymsg+yoffs, i, color)
end
MsgTable[i].timer = MsgTable[i].timer-1
if i["P1 Up" ] then u = "U" else u = " " end if MsgTable[i].timer <= 0 then
if i["P1 Down" ] then d = "D" else d = " " end MsgTable[i] = nil
if i["P1 Left" ] then l = "L" else l = " " end end
if i["P1 Right"] then r = "R" else r = " " end end
if i["P1 A" ] then a = "A" else a = " " end end
if i["P1 B" ] then b = "B" else b = " " end end
if i["P1 C" ] then c = "C" else c = " " end
if i["P1 Start"] then s = "S" else s = " " end local function PlayerBoxes()
if working > 0 then return end
text(1,10,u..d..l..r..a..b..c..s,"yellow") local xx = (Xpos-camx)/div
end local yy = (Ypos-camy)/div
local col = 0xff00ffff
event.onframeend(function() local swcol = col -- usual detection
emu.setislagged(rb(0xfff6d4)==0) if Yspd > 0 then -- gimme swings to grab!
swcol = 0xff00ff00
if rb(0xfff6d4)==0 then elseif Yspd == 0 then -- can tell that too
lagcount = lagcount+1 swcol = 0xffffffff
framecol = "red" end
else if facing == 2
framecol = "white" then box(xx-0xf /div-2, yy-0x2c/div-1, xx-0xf/div+0, yy-0x2c/div+1, swcol, 0) -- lefttop
end else box(xx+0xf /div , yy-0x2c/div-1, xx+0xf/div+2, yy-0x2c/div+1, swcol, 0) -- rightttop
end
emu.setlagcount(lagcount) box(xx -1, yy-0x2c/div-1, xx +1, yy-0x2c/div+1, col, 0) -- top
box(xx-0xf /div-2, yy-0x1f/div-1, xx-0xf /div+0, yy-0x1f/div+1, col, 0) -- left
rndlast = rnd1 box(xx+0x10/div-1, yy-0x1f/div-1, xx+0x10/div+1, yy-0x1f/div+1, col, 0) -- right
workinglast = working -- box(xx -1, yy-0x1f/div-1, xx +1, yy-0x1f/div+1, col, 0) -- center
XposLast = Xpos box(xx -1, yy-0x0f/div-1, xx +1, yy-0x0f/div+1, col, 0) -- bottom
YposLast = Ypos box(xx -1, yy -1, xx +1, yy +1,0xffffff00, 0) -- feet
end) -- box(xx -1, yy+0x10/div-1, xx +1, yy+0x10/div+1, col, 0) -- ground
end
while true do
main() local function Input()
emu.frameadvance() local i, u, d, l, r, a, b, c, s
if movie.isloaded()
then i = movie.getinput(emu.framecount()-1)
else i = joypad.getimmediate()
end
if i["P1 Up" ] then u = "U" else u = " " end
if i["P1 Down" ] then d = "D" else d = " " end
if i["P1 Left" ] then l = "L" else l = " " end
if i["P1 Right"] then r = "R" else r = " " end
if i["P1 A" ] then a = "A" else a = " " end
if i["P1 B" ] then b = "B" else b = " " end
if i["P1 C" ] then c = "C" else c = " " end
if i["P1 Start"] then s = "S" else s = " " end
text(1, 10, u..d..l..r..a..b..c..s, "yellow")
end
event.onframeend(function()
emu.setislagged(rb(0xfff6d4) == 0)
if rb(0xfff6d4) == 0 then
lagcount = lagcount+1
framecol = "red"
else
framecol = "white"
end
emu.setlagcount(lagcount)
wSize = client.getwindowsize()
rndlast = rnd1
workinglast = working
XposLast = Xpos
YposLast = Ypos
end)
event.onmemoryexecute(function()
local a0 = AND(emu.getregister("M68K A0"), 0xffffff)
if a0 ~= 0xff4044 then
for i = 1, 200 do
if MsgTable[i] == nil then
MsgTable[i] = { index = i, timer = MsgTime, base = a0 }
break
end
end
end
end, 0x257A, "RNGseed")
local function main()
rnd1 = rl (0xff001c)
rnd2 = rw (0xff0020)
working = rb (0xff0073)
xblocks = rw (0xff00d4)
mapw = rw (0xff00d4)*8
maph = rw (0xff00d6)*8
Xpos = rws(0xff0106)
Ypos = rws(0xff0108)
camx = rws(0xff010c)+16
camy = rws(0xff010e)+16
run = rb (0xff1699)
inv = rw (0xff16d2)
health = rws(0xff2cc6)
backx = camx
backy = camy
Xspd = Xpos-XposLast
Yspd = Ypos-YposLast
facing = AND(rb(GolBase+0x48), 2) -- object flag 1
if working > 0 then MsgTable = {} end
Background()
PlayerBoxes()
Objects()
PostRndRoll()
HUD()
RoomTime()
end
while true do
main()
emu.frameadvance()
end end