-- Radar HUD (By Kaphotics)
-- Enter the address of the Start of Slot Table
	local start=0x022A15A0
-- Enter the address of the X Position
	local pos=0x0227F458
-- Local Variables
local seed
local pkm
local lvl
local xp1
local xp2
local xp3
local xp4
local yp1
local yp2
local yp3
local yp4
local tp1
local tp2
local tp3
local tp4
local dp1
local dp2
local dp3
local dp4
local sp1
local sp2
local sp3
local sp4
-- Start Radar HUD
while true do
	-- Display the Seed ingame and in the Lua window
    		gui.text(0,16,"Seed: "..string.format("%8X", memory.readdwordunsigned(0x021BFB14)))
    		print(""..string.format("%8X", memory.readdwordunsigned(0x021BFB14)))
	-- Is the game currently chaining a Pokemon? If nothing is being chained, we don't display anything.
    if (memory.readdwordunsigned(start+540,2) == 0)
		then gui.text(1,64, string.format("Chain: Broken"))
		emu.frameadvance()
    else
	-- We're chaining something. Time to display what we're chaining.
		posx=memory.readwordunsigned(pos,4)
 		posy=memory.readwordunsigned(pos+4,4)
		
		chaincount=memory.readwordunsigned(start+528,2)
		gui.text(1,64, string.format("Chain: %d", chaincount))
		pkm=memory.readwordunsigned(start+532,2)
		gui.text(1,74, string.format("Dex: %d", pkm))
		lvl=memory.readwordunsigned(start+536,2)
		gui.text(1,84, string.format("Lvl: %d", lvl))
		gui.text(0,104,"Player:")
			gui.text(1,114,"X: "..string.format(posx))
			gui.text(1,124,"Y: "..string.format(posy))
		gui.text(0,144,"Patches:")
	-- Patch 1 Display -- 
		xp1=memory.readdwordunsigned(start+552,2)-posx
		yp1=memory.readdwordunsigned(start+556,2)-posy
		tp1=memory.readwordunsigned(start+560,2)
		dp1=memory.readdwordunsigned(start+564,2)
		sp1=memory.readwordunsigned(start+572,2)
			if xp1<0 then	gui.text(1,154,   string.format("X: %d", xp1))	else 	gui.text(1,154,   string.format("X:  %d", xp1))	end
			if yp1<0 then 	gui.text(51,154,  string.format("Y: %d", yp1))	else	gui.text(51,154,  string.format("Y:  %d", yp1))	end
			gui.text(101,154, string.format("Type: %d", tp1))
			if dp1==0 then	gui.text(171,154, string.format("Disabled"))	end
			if sp1==1 then	gui.text(171,154, string.format("Shiny!"))	end
	-- Patch 2 Display -- 
		xp2=memory.readdwordunsigned(start+592,2)-posx
		yp2=memory.readdwordunsigned(start+596,2)-posy
		tp2=memory.readwordunsigned(start+600,2)
		dp2=memory.readwordunsigned(start+604,2)
		sp2=memory.readwordunsigned(start+612,2)
			if xp2<0 then	gui.text(1,164,   string.format("X: %d", xp2))	else	gui.text(1,164,   string.format("X:  %d", xp2))	end
			if yp2<0 then	gui.text(51,164,  string.format("Y: %d", yp2))	else	gui.text(51,164,  string.format("Y:  %d", yp2))	end
			gui.text(101,164, string.format("Type: %d", tp2))
			if dp2==0 then	gui.text(171,164, string.format("Disabled"))	end
			if sp2==1 then	gui.text(171,164, string.format("Shiny!"))	end
	-- Patch 3 Display --	
		xp3=memory.readdwordunsigned(start+632,2)-posx
		yp3=memory.readdwordunsigned(start+636,2)-posy
		tp3=memory.readwordunsigned(start+640,2)
		dp3=memory.readwordunsigned(start+644,2)
		sp3=memory.readwordunsigned(start+652,2)
			if xp3<0 then	gui.text(1,174,   string.format("X: %d", xp3))	else 	gui.text(1,174,   string.format("X:  %d", xp3))	end
			if yp3<0 then 	gui.text(51,174,  string.format("Y: %d", yp3))	else	gui.text(51,174,  string.format("Y:  %d", yp3))	end
			gui.text(101,174, string.format("Type: %d", tp3))
			if dp3==0 then	gui.text(171,174, string.format("Disabled")) 	end
			if sp3==1 then	gui.text(171,174, string.format("Shiny!")) 	end
	-- Patch 4 Display --
		xp4=memory.readdwordunsigned(start+672,2)-posx
		yp4=memory.readdwordunsigned(start+676,2)-posy
		tp4=memory.readwordunsigned(start+680,2)
		dp4=memory.readwordunsigned(start+684,2)
		sp4=memory.readwordunsigned(start+692,2)
			if xp4<0 then	gui.text(1,184,   string.format("X: %d", xp4))	else	gui.text(1,184,   string.format("X:  %d", xp4))	end
			if yp4<0 then	gui.text(51,184,  string.format("Y: %d", yp4))	else	gui.text(51,184,  string.format("Y:  %d", yp4))	end
			gui.text(101,184, string.format("Type: %d", tp4))
			if dp4==0 then	gui.text(171,184, string.format("Disabled")) end
			if sp4==1 then	gui.text(171,184, string.format("Shiny!")) end
		
		
	-- End Dynamic Display
	emu.frameadvance()
    end
end