User File #32864750885547067

Upload All User Files

#32864750885547067 - Crash Bandicoot [J] - Lua script for BizHawk

crashJ-bizhawk.lua
1069 downloads
Uploaded 8/11/2016 1:20 AM by Amaraticando (see all 21)
local HEADER = 0x56698
--local HEADER = 0x566B4
local pScale = 1024
local vScale = 102400/3
xx = {}
yy = {}
zz = {}

event.onframeend(function()
	local addr = mainmemory.read_u32_le(HEADER)

	if addr ~= 0 then
		addr = addr -0x80000000
	else
		gui.text(8,48,"")
		return
	end
	local X  = mainmemory.read_s32_le( addr + 0x80 ) / pScale
	local Y  = mainmemory.read_s32_le( addr + 0x88 ) / pScale
	local Z  = mainmemory.read_s32_le( addr + 0x84 ) / pScale
	local XV = mainmemory.read_s32_le( addr + 0xA4 ) / vScale
	local YV = mainmemory.read_s32_le( addr + 0xAC ) / vScale
	local ZV = mainmemory.read_s32_le( addr + 0xA8 ) / vScale
	local V  = mainmemory.read_s32_le( addr + 0x124) / vScale
	local XY = math.sqrt(XV*XV+YV*YV)
	local D  = mainmemory.read_s16_le(  addr + 0xB4 ) / 4096*360
	local BOX = mainmemory.read_u8(0x6196D)
	local Level = mainmemory.read_u16_le(0x618C4)
	local jump = mainmemory.read_u16_le( addr + 0x1A1 )
	local spin = math.min(mainmemory.read_u32_le( addr + 0xFC ) -  mainmemory.read_u32_le( addr + 0x194 ),300)/60
	local f = emu.framecount()
	xx[f] = X
	yy[f] = Y
	zz[f] = Z

	local x, y, dy = 8, 48, 14
	local function print_info(format, ...)
		gui.text(x, y, string.format(format, ...))
		y = y + dy
	end

	print_info("%8d : Box", BOX)
	print_info("%8d : Jump", jump)
	print_info("%8.2f : Z  Pos", Z, ZV)
	print_info("%8.2f : Z  Vel", ZV)
	print_info("%8.2f : X  Pos", X, XV)
	print_info("%8.2f : X  Vel", XV)
	print_info("%8.2f : Y  Pos", Y, YV)
	print_info("%8.2f : Y  Vel", YV)
	print_info("%8.2f : XY VeL", XY)
	print_info("%8.2f : Velocity", V)
	print_info("%8.2f : Degree", D)
	print_info("%8.2f : SpinPow", spin)
	print_info("%8.2f : X-2f", X - (xx[f-2] or 0))
	print_info("%8.2f : Y-2f", Y - (yy[f-2] or 0))
	print_info("%8.2f : Z-2f", Z - (zz[f-2] or 0))

end, "crashJ-script")