User File #638491196753996768

Upload All User Files

#638491196753996768 - Zillion - Lua Script

Zilliion Right.lua
Game: Zillion ( SMS, see all files )
40 downloads
Uploaded 4/19/2024 10:34 AM by The8bitbeast (see all 37)
Useful info for Zillion
oldxPos = 0
oldyPos = 0
oldsxPos = 0

local oldPV = 0;
bestr = {}
bestl = {}

local deltaPpm = "1"
local deltaPComp = 0
local deltaSComp = 0
local deltaPfr = 0
local lastDeltaP = 0
local lastDeltaS = 0
local lastDeltaPCurPos = 0
local lastDeltaSCurPos = 0
local save = false
local tInc = -0.5
local tRoot = 0
local fRoot = 0
local lagLog = {}
local lagSmoothLog = {}
moveRight = 1

local usualSpeed = 384
local usualScreen = 128*256
horzDisp = 600



function doStuff()
    fr = emu.framecount()
    newR = ""
    if bestr[fr] == nil then
	bestr[fr] = -1000000000
    end
    x1 = 0 --mainmemory.readbyte(0x0302)--Subpixel
    x2 = -mainmemory.readbyte(0x0303) + mainmemory.readbyte(0x0323)--Pixel



    x3 = mainmemory.readbyte(0x034C)+10--Superpixel

x3 = -x3+20
x2 = -x2+256

while x2 > 255 do
	x3 = x3+1
	x2 = x2-256
end



   	--xPos = -x3*256 + x2 --+ x1
    

   	xPos = x3*256*256 + x2*256 + x1
    
if moveRight == 1 then 
if xPos < bestr[fr] then
	col = "red"
else
	col = "green"
end
else
if xPos > bestr[fr] then
	col = "red"
else
	col = "green"
end
end
    y1 = 0 mainmemory.readbyte(0x0304)--Subpixel
    y2 = mainmemory.readbyte(0x0305)--Pixel
    y3 = 0 --mainmemory.readbyte(0xA2D4)--Superpixel
    yPos = y3*256*256 + y2*256 + y1


code1 = mainmemory.readbyte(0x01F0)
code2 = mainmemory.readbyte(0x01F1)
code3 = mainmemory.readbyte(0x01F2)
code4 = mainmemory.readbyte(0x01F3)

temp1 = (code1-1)%11+1
temp2 = (code2-1)%11+1
temp3 = (code3-1)%11+1
temp4 = (code4-1)%11+1


minCode = math.min(temp1,temp2,temp3,temp4)



    vx1 = 0 --mainmemory.readbyte(0xA2DA) --Subpixel
    vx2 =  0 --mainmemory.readbyte(0xA2D9) --Pixel
    xVel = vx2*256+vx1
    if moveRight == 1 then
    if bestr[fr] < xPos then
	newR = "oldR: "..string.upper(string.format("%x", math.floor(bestr[fr]/65536))).." "..string.upper(string.format("%x",math.floor((bestr[fr]%65536)/256))).." "..string.upper(string.format("%x",math.floor((bestr[fr]%256))))
	bestr[fr] = xPos
	if save == true then
	if vx1 > 2 then
		if fr%20 == 0 then
			movie.save("C:/Users/Jake/Desktop/TAS/BizHawk-2.8-win-x64/Movies/Sonic Blast/Logs/"..fr.."-"..string.upper(string.format("%x", math.floor(bestr[fr]/65536))).." "..string.upper(string.format("%x",math.floor((bestr[fr]%65536)/256))).." "..string.upper(string.format("%x",math.floor((bestr[fr]%256)))))
		end
	end
	end
    end
    else
    if bestr[fr] > xPos then
	newR = "oldR: "..string.upper(string.format("%x", math.floor(bestr[fr]/65536))).." "..string.upper(string.format("%x",math.floor((bestr[fr]%65536)/256))).." "..string.upper(string.format("%x",math.floor((bestr[fr]%256))))
	bestr[fr] = xPos
	if save == true then
	if vx1 > 2 then
		if fr%20 == 0 then
			movie.save("C:/Users/Jake/Desktop/TAS/BizHawk-2.8-win-x64/Movies/Sonic Blast/Logs/"..fr.."-"..string.upper(string.format("%x", math.floor(bestr[fr]/65536))).." "..string.upper(string.format("%x",math.floor((bestr[fr]%65536)/256))).." "..string.upper(string.format("%x",math.floor((bestr[fr]%256)))))
		end
	end
	end
    end
    end
    
    vy1 = 0 --mainmemory.readbyte(0xA2DE)
    vy2 =  0 --mainmemory.readbyte(0xA2DD)
    yVel = vy2*256 + vy1
	

    dx = xPos - oldxPos
    dy = yPos - oldyPos

    oldxPos = xPos
    oldyPos = yPos
    
    gui.text(horzDisp,200,"xPos: "..string.upper(string.format("%x", x3)).." "..string.upper(string.format("%x", x2)).." "..string.upper(string.format("%x", x1)),col)
    gui.text(horzDisp,220,"xSpd: "..string.upper(string.format("%x", vx2)).." "..string.upper(string.format("%x", vx1)))
    gui.text(horzDisp,240,"  dx: "..string.upper(string.format("%x", dx)))
    
    gui.text(horzDisp,280,"yPos: "..string.upper(string.format("%x", y2)).." "..string.upper(string.format("%x", y1)))
    gui.text(horzDisp,300,"ySpd: "..string.upper(string.format("%x", vy2)).." "..string.upper(string.format("%x", vy1)))
    gui.text(horzDisp,320,"  dy: "..string.upper(string.format("%x", dy)))

if minCode < 6 then
	col = "red"
elseif minCode == 6 then
	col = "yellow"
else
	col = "green"
end

    gui.text(horzDisp,360,"  Codes: "..code1..code2..code3..code4)
    gui.text(horzDisp,380,"  Min Code: "..minCode,col)




	
	deltaPCurPos = xPos

    	if deltaPCurPos ~= lastDeltaPCurPos then
        	lastDeltaP = deltaPCurPos - (deltaPComp + deltaPpm * usualSpeed * (emu.framecount() - deltaPfr))	
    	end

    	lastDeltaPCurPos = deltaPCurPos
	lastDeltaSCurPos = deltaSCurPos
    	gui.text(horzDisp,500,"  dP: "..lastDeltaP)
        gui.text(horzDisp,520,"  dPH: "..string.upper(string.format("%x", lastDeltaP)))
	gui.text(horzDisp,540,"  dS: "..lastDeltaS)
        gui.text(horzDisp,560,"  dSH: "..string.upper(string.format("%x", lastDeltaS)))
	

	gui.text(horzDisp,180,newR)
	gui.text(horzDisp,160,"BesR: "..string.upper(string.format("%x", math.floor(bestr[fr]/65536))).." "..string.upper(string.format("%x",math.floor((bestr[fr]%65536)/256))).." "..string.upper(string.format("%x",math.floor((bestr[fr]%256)))))
	--gui.text(horzDisp,140,"Bestl: "..string.upper(string.format("%x", math.floor(bestl[fr]/65536))).." "..string.upper(string.format("%x",math.floor((bestl[fr]%65536)/256))).." "..string.upper(string.format("%x",math.floor((bestl[fr]%256)))))
end

event.onframeend(doStuff)

function dP(pm)
	deltaPpm = pm
	deltaPfr = emu.framecount()
	deltaPComp = xPos
	deltaSComp = sxPos
end

function tRes()
    tRoot = getTimerVal()
    fRoot = emu.framecount()
end



function res()
	bestr = {}
	bestl = {}
end

function nosave()
	save = false
end

function yessave()
	save = true
end

function getTimerVal()
    tH = mainmemory.readbyte(0x1FC5)
    tT = mainmemory.readbyte(0x1FC4)
    tU = mainmemory.readbyte(0x1FC3)
    tM = mainmemory.readbyte(0x1FC2)
    return (tH*100+tT*10+tU)*30+tM
end

tRes()