User File #47703003744204809

Upload All User Files

#47703003744204809 (unlisted) -

Bonk's Adventure.lua
42 downloads
Uploaded 6/10/2018 7:13 AM by TASeditor (see all 188)
function Color(index, column)

	if xDirectionTable[index] ~= nil and xSpeedTable[index] ~= nil
	then if column == "P1 Right" and xDirectionTable[index] < 4
		 then if xSpeedTable[index] < 4
			  then red = 255
				   green = math.floor((255/4)*xSpeedTable[index])
				   blue = 0
			  else red = math.floor(-(255/4)*xSpeedTable[index])
				   green = 255
				   blue = 0
			  end
			  return red*256*256+green*256+blue
		 elseif column == "P1 Left" and xDirectionTable[index] >= 4
			 then if xSpeedTable[index] < 4
				  then red = 255
					   green = math.floor((255/4)*xSpeedTable[index])
					   blue = 0
				  else red = math.floor(-(255/4)*xSpeedTable[index])
					   green = 255
					   blue = 0
				  end
				  return red*256*256+green*256+blue
		 end
		 
	end

end

xDirectionTable = {}
xSpeedTable = {}
ySpeedTable = {}

ug = 0
x = 0

memory.usememorydomain("RAM")

tastudio.onqueryitembg(Color)


while true do
	
	f = emu.framecount()
	
	if f > ug
	then ug = f
	end
	
	xOld = x
	
	local xCamera = memory.read_u16_le(0x0053)
		
	local xDirection = memory.read_u8(0x0342)
	
	local xOnScreen = memory.read_u8(0x034E)
	local xOffScreen = memory.read_s8(0x0354)		
	local yOnScreen = memory.read_u8(0x035A)
	local yOffScreen = memory.read_s8(0x0360)
	local xSpeed = memory.read_u8(0x0366)
	local xSpeedState = memory.read_u8(0x036C)
	local xSubpixel = memory.read_u8(0x0372)
	
	local ySpeed = memory.read_u8(0x037E)
	local ySpeedState = memory.read_u8(0x0384)
	local ySubpixel = memory.read_u8(0x38A)	

	x = (xOnScreen+xOffScreen+xCamera)*64+xSubpixel
	
	
	xDirectionTable[f] = xDirection
	xSpeedTable[f] = xSpeed
	ySpeedTable[f] = ySpeed
	
	gui.drawText(0,30, "X Speed:"..xSpeed.." ", 0xFFFFFFFF, 0x99990000)
	gui.drawText(0,45, "Y Speed:"..ySpeed.." ", 0xFFFFFFFF, 0x99009900)
	gui.drawText(0,60, "X Position:"..xOnScreen+xOffScreen+xCamera..":"..xSubpixel.." ", 0xFFFFFFFF, 0x99990000)
	gui.drawText(0,75, "Y Position:"..yOnScreen+yOffScreen..":"..ySubpixel.." ", 0xFFFFFFFF, 0x99009900)
	
	if x == xOld
	then tastudio.setlag(f, true)
	end
	
	
	emu.frameadvance();
end