Untitled

 avatar
unknown
plain_text
a year ago
15 kB
9
Indexable
-----------sniq-----------------------------

textStepSmall = 11
camFlag = 0

function camToggle()
	
	if (camFlag < 1)
	then
		camFlag = camFlag + 1
	else
		camFlag = 0
	end
end

function BlockHitboxes()


	local screenX = mainmemory.read_u16_le(0x001C)
    local screenY = mainmemory.read_u16_le(0x001E)
	
	local branch = mainmemory.read_u16_le(0x00AE)
	local indexThing = mainmemory.read_u16_le(0x0542)
	
	local posX = mainmemory.read_u16_le(0x054A)
	local posY = (mainmemory.read_u16_le(0x054E) + 6)
	
	cameraX, cameraY = posX-128 & 0xFFFF, posY-112 & 0xFFFF
	--[[
	if cameraX >= 10000 then
		cameraX = cameraX-65535
    end
 
	if cameraY >= 10000 then
		cameraY = cameraY-65535
	end
	]]--
	
	if (camFlag == 1)
	then
		screenX = cameraX
		screenY = cameraY
	end
	
	if (branch == 0x0000 or branch == 0x0001 or (branch == 0x0003 and indexThing == 0x8018))
	then
		for y=0,28 do
			for x=0,32 do
			
				local BlockX = x*8 - (screenX & 0x0007)
				local BlockY = y*8 - (screenY & 0x0007)
				
				local adjustedX = (x * 8) + screenX
				local adjustedY = (y * 8) + screenY
				
				local blockVar = ((adjustedX & 0x0100) << 2)
				blockVar = (((adjustedX >> 3) & 0x001F) | blockVar)
				blockVar = (((adjustedY & 0x0100) << 3) | blockVar)
				local blockIndex = ((((adjustedY << 2) & 0x03E0) | blockVar) << 1)
				local blocktype
					
				blockType = mainmemory.read_u16_le(0x4000 + blockIndex)
				
				if (blockType == 0x0001)
				then 
					gui.drawBox(BlockX, BlockY, BlockX + 8, BlockY + 8, 0xFFFFFFFF, 0x35FF0000)
				elseif (blockType == 0x8000 or blockType == 0x8001)
				then 
					gui.drawBox(BlockX, BlockY, BlockX + 8, BlockY + 8, 0xFF00FF00, 0x35FF0000)
				elseif (blockType == 0x0000)
				then
				
				elseif (blockType == 0x0004)
				then
					gui.drawBox(BlockX, BlockY + 4, BlockX + 8, BlockY + 8, 0xFFFFFFFF, 0x35FF0000)
				else
					gui.text(BlockX * 2, BlockY * 2, string.format("%02X", blockType), 0xFF00FF00, 0x35FF0000)
				end					
			end
		end
	elseif (branch == 0x0003 and indexThing == 0x0000)
	then
		for y=0,28 do
			for x=0,32 do
			
				local BlockX = x*8 - ((screenX & 0x0007))
				local BlockY = y*8 - ((screenY & 0x0007))
				
				local adjustedX = (x * 8) + screenX
				local adjustedY = (y * 8) + screenY
				
				local blockVar = ((adjustedX & 0x0100) << 2)
				blockVar = (((adjustedX >> 3) & 0x001F) | blockVar)
				blockVar = (((adjustedY & 0x0100) << 3) | blockVar)
				local blockIndex = ((((adjustedY << 2) & 0x03E0) | blockVar) << 1)
				local blocktype
					
				blockType = mainmemory.read_u16_le(0xA000 + blockIndex)
				
				if (blockType == 0x0001)
				then 
					gui.drawBox(BlockX, BlockY, BlockX + 8, BlockY + 8, 0xFFFFFFFF, 0x35FF0000)
				elseif (blockType == 0x8000 or blockType == 0x8001)
				then 
					gui.drawBox(BlockX, BlockY, BlockX + 8, BlockY + 8, 0xFF00FF00, 0x35FF0000)
				elseif (blockType == 0x0000)
				then
				
				elseif (blockType == 0x0004)
				then
					gui.drawBox(BlockX, BlockY + 4, BlockX + 8, BlockY + 8, 0xFFFFFFFF, 0x35FF0000)	
				else
					gui.text(BlockX * 2, BlockY * 2, string.format("%02X", blockType), 0xFF00FF00, 0x35FF0000)
				end					
			end
		end
	end
end


--[[function ObjectHitboxes()

	local screenX = memory.readword('WRAM', 0x001C) * 2
    local screenY = memory.readword('WRAM', 0x001E) * 2
	
	local posXPlayer = memory.readword('WRAM', 0x054A) * 2
	local posYPlayer = (memory.readword('WRAM', 0x054E) + 6) * 2
	
	if (camFlag == 0)
	then
		for i = 0, 36 do
		
			local objectID = memory.readword('WRAM', 0x0590 + (i * 0x40))
			
			local posX = memory.readword('WRAM', 0x058A + (i * 0x40)) * 2
			local posY = (memory.readword('WRAM', 0x058E + (i * 0x40)) * 2)
			
			local sizeX = memory.readword('WRAM', 0x05A8 + (i * 0x40)) * 2
			local sizeY = memory.readword('WRAM', 0x05AA + (i * 0x40)) * 2 
			
			local hp = memory.readword('WRAM', 0x0586 + (i * 0x40))
			
			if (objectID ~= 0x2F)
			then
				gui.rectangle(posX-screenX-sizeX, posY-screenY-sizeY, (sizeX * 2) + 2, (sizeY * 2) + 10, 1, 0xFF00FF)
				gui.text(posX-screenX-8, posY-screenY-8, string.format("%02X", objectID), 0x00FF00)
			else
				gui.rectangle(posX-screenX-sizeX, posY-screenY-sizeY, (sizeX * 2) + 2, (sizeY * 2) + 10, 1, 0x00FFFF)
				gui.text(posX-screenX-8, posY-screenY-8, string.format("%02X", objectID), 0x00FF00)
			end
			
			--gui.text(5, 10 + (textStepSmall * i), "#" .. (i + 1) .. ": " .. string.format("%02X HP = %d", objectID, hp))
			if (objectID ~= 0)
			then
				gui.text(5, 10 + (textStepSmall * i), "#" .. (i + 1) .. ": " .. string.format("%02X", objectID))
			else
				gui.text(5, 10 + (textStepSmall * i), "#" .. (i + 1) .. ": ")
			end
			
		end
	else
		for i = 0, 36 do
		
			local objectID = memory.readword('WRAM', 0x0590 + (i * 0x40))
			
			local posX = memory.readword('WRAM', 0x058A + (i * 0x40)) * 2
			local posY = (memory.readword('WRAM', 0x058E + (i * 0x40)) * 2)
			
			local sizeX = memory.readword('WRAM', 0x05A8 + (i * 0x40)) * 2
			local sizeY = memory.readword('WRAM', 0x05AA + (i * 0x40)) * 2 
			
			local cameraX, cameraY = bit.band(posXPlayer-128, 0xFFFF), bit.band(posYPlayer-112, 0xFFFF)
			if cameraX >= 10000 then
				cameraX = cameraX-65535
			end
		 
			if cameraY >= 10000 then
				cameraY = cameraY-65535
			end
			
			screenX = cameraX
			screenY = cameraY
			
			local hp = memory.readword('WRAM', 0x0586 + (i * 0x40))
			
			if (objectID ~= 0x2F)
			then
				gui.rectangle(posX-screenX-sizeX + 128, posY-screenY-sizeY + 112, (sizeX * 2) + 2, (sizeY * 2) + 10, 1, 0xFF00FF)
				gui.text(posX-screenX-8 + 128, posY-screenY-8 + 112, string.format("%02X", objectID), 0x00FF00)
			else
				gui.rectangle(posX-screenX-sizeX + 128, posY-screenY-sizeY + 112, (sizeX * 2) + 2, (sizeY * 2) + 10, 1, 0x00FFFF)
				gui.text(posX-screenX-8 + 128, posY-screenY-8 + 112, string.format("%02X", objectID), 0x00FF00)
			end
			
			--gui.text(5, 10 + (textStepSmall * i), "#" .. (i + 1) .. ": " .. string.format("%02X HP = %d", objectID, hp))
			if (objectID ~= 0)
			then
				gui.text(5, 10 + (textStepSmall * i), "#" .. (i + 1) .. ": " .. string.format("%02X", objectID))
			else
				gui.text(5, 10 + (textStepSmall * i), "#" .. (i + 1) .. ": ")
			end
			
		end
	end



end

function PlayerHitbox()

	local screenX = memory.readword('WRAM', 0x001C) * 2
    local screenY = memory.readword('WRAM', 0x001E) * 2
	local mvmtType = memory.readword('WRAM', 0x0552)
	
	local posX = memory.readword('WRAM', 0x054A) * 2
	local posY = (memory.readword('WRAM', 0x054E) + 6) * 2
		
	local sizeX = memory.readword('BUS', 0x0190F7) * 2
	local sizeY = (memory.readword('WRAM', 0x0576)) * 2
	
		
	
	if (camFlag == 0)
	then
		if (mvmtType ~= 0x04)
		then
			gui.rectangle(posX-screenX-sizeX, posY-screenY-sizeY, (sizeX * 2) + 2, (sizeY * 2) - 12, 1, 0xFFFF00)
		else
			gui.rectangle(posX-screenX-sizeX, posY-screenY-sizeY, (sizeX * 2) + 2, (sizeY * 2) - 42, 1, 0xFFFF00)
		end
	else
		if (mvmtType ~= 0x04)
		then
			gui.rectangle(256 - sizeX, 224 - sizeY, (sizeX * 2) + 2, (sizeY * 2) - 12, 1, 0xFFFF00)
		else
			gui.rectangle(256 - sizeX, 224 - sizeY, (sizeX * 2) + 2, (sizeY * 2) - 42, 1, 0xFFFF00)
		end
	end
	
	



end

function AttackHitbox()

	local screenX = memory.readword('WRAM', 0x001C) * 2
    local screenY = memory.readword('WRAM', 0x001E) * 2
	local objectID = memory.readword('WRAM', 0x0450)
	
	local posX = memory.readword('WRAM', 0x044A) * 2
	local posY = (memory.readword('WRAM', 0x044E) + 6) * 2
	
	local sizeX = (memory.readword('WRAM', 0x0468) * 2)
	local sizeY = (memory.readword('WRAM', 0x046A) * 2)
			
	
	if (objectID == 0x04)
	then
		gui.rectangle(posX-screenX-sizeX-4, posY-screenY-sizeY-4, (sizeX * 2), (sizeY * 2), 1, 0xFFFF00)
	end


end
]]
--[[function toggle()

	
	--which list to display: 0 = nothing, 1 = 128-byte list, 2 = 64-byte list, 3 = 32-byte list. I've bound this function to z button.
	if (camFlag < 1)
	then
		camFlag = 1
	else
		camFlag = 0
	end
end]]


-------end sniq-----------------------------

----------------------------
----Super Castlevania IV----
----------------------------

--Author Pasky13

---------------
----TOGGLES----
---------------

--Box type toggles
local candle = true
local enemy = true
local player = true


--Center axis toggles
local player_axis = false
local whip_axis = false
local projectile_axis = true
local enemy_axis = true
local candle_axis = false

--Hitpoint display
local playerhp = true
local enemyhp = true

--Cheats
local cheats = false

------------------
---END TOGGLES----
------------------


---------------
----GLOBALS----
---------------

local pbase = 0x540
local ebase = 0x580
local wbase = 0x200
local pjbase = 0x440

local ux = 0xA
local uy = 0xE

local uxrad = 0x28
local uyrad = 0x2A

local eactive = 0x10

local camx = 0x1280
local camy = 0x1298

local elife = 0x06

local plife = 0x13F4
local hearts = 0x13F2
local facing = 0x0578
local timer = 0x13F0

local xs = client.screenwidth() / 256
local ys = client.screenheight() / 224



-------------------
----END GLOBALS----
-------------------

local function centeraxis(x,y)
	gui.drawLine(x,y+2,x,y-2,0xFFFFFFFF)
	gui.drawLine(x+2,y,x-2,y,0xFFFFFFFF)
end

local function player_hitbox()
	local x = mainmemory.read_u16_le(pbase+ux) - mainmemory.read_u16_le(camx)
	local y = mainmemory.read_u16_le(pbase+uy) - mainmemory.read_u16_le(camy)
	local cr = mainmemory.read_u8(0x576)
	

	
	-----sniq adjustment-------
	
	if (camFlag == 1)
	then
		x = 0x80
		y = 0x69
	end
	local mvmtType = mainmemory.read_u16_le(0x0552)
	
	
	if (mvmtType == 0x04)
	then
		if cr ~= 0x0F then
			gui.drawBox(x+7,y+27-15,x-7,y-19,0xFF0000FF,0x400000FF)
			if playerhp == true then
				gui.text((x-10) * xs,(y-26) * ys,"HP:" .. mainmemory.read_u8(plife))
			end
		else
			gui.drawBox(x+7,y+cr,x-7,y-cr,0xFF0000FF,0x400000FF)
				if playerhp == true then
					gui.text((x-10) * xs,(y-cr-7) * ys,"HP:" .. mainmemory.read_u8(plife))
				end
		end
	else
		if cr ~= 0x0F then
			gui.drawBox(x+7,y+27,x-7,y-19,0xFF0000FF,0x400000FF)
			if playerhp == true then
				gui.text((x-10) * xs,(y-26) * ys,"HP:" .. mainmemory.read_u8(plife))
			end
		else
			gui.drawBox(x+7,y+cr,x-7,y-cr,0xFF0000FF,0x400000FF)
				if playerhp == true then
					gui.text((x-10) * xs,(y-cr-7) * ys,"HP:" .. mainmemory.read_u8(plife))
				end
		end
	end
	
	
	
	if player_axis == true then
		centeraxis(x,y)
	end
	
end

local function player_projectiles()
	local base = 0
	local x
	local y
	local xrad
	local yrad
	local oend = 3
	
	for i = 0,oend,1 do
	
		base = pjbase + (i * 0x40)
		
		if i == 0 then
			base = pjbase
		end
		
		if mainmemory.read_u16_le(base) ~= 0 then
			x = mainmemory.read_u16_le(base+ux) - mainmemory.read_u16_le(camx)
			y = mainmemory.read_u16_le(base+uy) - mainmemory.read_u16_le(camy)
			xrad = mainmemory.read_u16_le(base+uxrad)
			yrad = mainmemory.read_u16_le(base+uyrad)
			gui.drawBox(x-xrad,y-yrad,x+xrad,y+yrad,0xFFFFFFFF,0x40FFFFFF)
			
			if projectile_axis == true then
				centeraxis(x,y)
			end
			
		end
		
	end
end

local function player_whip()

	local base = 0
	local x
	local y
	local xrad
	local yrad
	local oend = 8
	
	for i = 0,oend,1 do
	
		base = wbase + (i * 0x40)
		
		if i == 0 then
			base = wbase
		end
		
		if mainmemory.read_u16_le(base) ~= 0 then
			x = mainmemory.read_u16_le(base+ux) - mainmemory.read_u16_le(camx)
			y = mainmemory.read_u16_le(base+uy) - mainmemory.read_u16_le(camy)
			xrad = mainmemory.read_u16_le(base+uxrad)
			yrad = mainmemory.read_u16_le(base+uyrad)
			
			if xrad == 0 and yrad == 0 then
				if base == 0x0400 then
					gui.drawBox(x-0x10,y-0x04,x+0x10,y+0x04,0xFFFFFFFF,0x40FFFFFF)
				else
					gui.drawBox(x-0x04,y-0x04,x+0x04,y+0x04,0xFFFFFFFF,0x40FFFFFF)
				end
			else
				gui.drawBox(x-xrad,y-yrad,x+xrad,y+yrad,0xFFFFFFFF,0x40FFFFFF)
			end
			
			if whip_axis == true then
				centeraxis(x,y)
			end
		end
		
	end
end

local function object_hitbox()
	local base = 0
	local x 
	local y
	local xrad
	local yrad
	local oend = 36
	local drawn
	local life 
	for i = 0,oend,1 do
	
		base = ebase + (i * 0x40)
		drawn = false
		
		if i == 0 then
			base = ebase
		elseif
			base == 0x540 then
			drawn = true
		end
		
		if mainmemory.read_u16_le(base+0x10) == 0x0E then
			if candle == true then
				x = mainmemory.read_u16_le(base+ux) - mainmemory.read_u16_le(camx)
				y = mainmemory.read_u16_le(base+uy) - mainmemory.read_u16_le(camy)
				xrad = mainmemory.read_u16_le(base+uxrad)
				yrad = mainmemory.read_u16_le(base+uyrad)
				gui.drawBox(x-xrad,y-yrad,x+xrad,y+yrad,0xFFFFD000,0x40FFD000)
				drawn = true
				
				if candle_axis == true then
					centeraxis(x,y)
				end
			end
			
		end
		
		if mainmemory.read_u16_le(base+0x10) ~= 0 and drawn == false then
		
			x = mainmemory.read_u16_le(base+ux) - mainmemory.read_u16_le(camx)
			y = mainmemory.read_u16_le(base+uy) - mainmemory.read_u16_le(camy)
			xrad = mainmemory.read_u16_le(base+uxrad)
			yrad = mainmemory.read_u16_le(base+uyrad)
			life = mainmemory.read_u16_le(base+elife)
			
			gui.drawBox(x-xrad,y-yrad,x+xrad,y+yrad,0xFFFF0000,0x40FF0000)
			drawn = true
			
			if enemyhp == true then
				if life > 0 and life ~= 255 then
					gui.text((x-10) * xs,(y-yrad-7) * ys,"HP:" .. life)
				end
			end
			if enemy_axis == true then
				centeraxis(x,y)
			end
		end
		
		
	end
end

local function cheat()
	memory.writebyte(plife,16)
	memory.writeword(timer,1024)
	memory.writebyte(hearts,32)
end

local function scaler()
	xs = client.screenwidth() / 256
	ys = client.screenheight() / 224
end


while true do
------------sniq------------------
--AttackHitbox()
--PlayerHitbox()
--ObjectHitboxes()
BlockHitboxes()

if (mainmemory.read_u16_le(0x0020) == 0x2080 and mainmemory.read_u16_le(0x0028) == 0x2000)
then
	camToggle()
end
------------end sniq--------------------
------------pasky-----------------
	scaler()

	if player == true then
		player_hitbox()
		player_whip()
		player_projectiles()
	end
	
	if (camFlag == 0)
	then
		if enemy == true then
			object_hitbox()
		end
	end
	if cheats == true then
		cheat()
	end
----------end pasky----------------------
emu.frameadvance()
end
Editor is loading...
Leave a Comment