User File #47351401452712727

Upload All User Files

#47351401452712727 - Kuru Kuru Kururin - OoB view v1.1

Kururin OoB view v1.1.lua
832 downloads
Uploaded 5/25/2018 11:11 AM by ThunderAxe31 (see all 111)
It now correctly displays the whole OoB world.
TODO:
find all wall tile types
helirin display
--Kuru Kuru Kururin - OoB view v1.1 by ThunderAxe31
--TODO:
--find all wall tile types
--helirin display

local addr_map_x_size = 0x313E
local addr_map_y_size = 0x313C
local addr_x_pos      = 0x4546
local addr_y_pos      = 0x454A
local addr_rotate     = 0x4573

local x_end = 32
local y_end = 32

local view_win = gui.createcanvas(255, 255)
	
view_win.SetTitle("Out of Bounds Viewer") 

while true do
	local map_x_size = memory.read_u16_le(addr_map_x_size, "IWRAM")
	local map_y_size = memory.read_u16_le(addr_map_y_size, "IWRAM")
	local x_pos = memory.read_s16_le(addr_x_pos, "IWRAM") -111
	local y_pos = (memory.read_s16_le(addr_y_pos, "IWRAM") -127)%(map_x_size*8)
	local x_mod = x_pos%8
	local y_mod = y_pos%8
	local x_pos_floor = math.floor(x_pos/8)
	local y_pos_floor = math.floor(y_pos/8)
	
	view_win.Clear(0xFFFFFFFF)
	
	for y=0, y_end do
		for x=0, x_end do
			local tile_addr = (x_pos_floor +x)*2 +((y_pos_floor +y) %map_x_size) *map_y_size *2
			local tile_type = memory.read_u16_be(0x02000000 +tile_addr)
			local x_tile = x*8 -x_mod
			local y_tile = y*8 -y_mod
			if (tile_type == 0x0300) or (tile_type == 0x0304) or (tile_type == 0x0308) or (tile_type == 0x030C) or (tile_type == 0x0400) or (tile_type == 0x0404) or (tile_type == 0x0408) or (tile_type == 0x040C) or (tile_type == 0x2100) or (tile_type == 0x2104) or (tile_type == 0x2108) or (tile_type == 0x210C) or (tile_type == 0x3300) or (tile_type == 0x3304) or (tile_type == 0x3308) or (tile_type == 0x330C) or (tile_type == 0x4100) or (tile_type == 0x4104) or (tile_type == 0x4108) or (tile_type == 0x410C) or (tile_type == 0x3500) or (tile_type == 0x3504) or (tile_type == 0x3508) or (tile_type == 0x350C) or (tile_type == 0x3000) or (tile_type == 0x3004) or (tile_type == 0x3008) or (tile_type == 0x300C) or (tile_type == 0x2400) or (tile_type == 0x2404) or (tile_type == 0x2408) or (tile_type == 0x240C) or (tile_type == 0x0500) or (tile_type == 0x0504) or (tile_type == 0x0508) or (tile_type == 0x050C) then
				view_win.DrawRectangle(x_tile, y_tile, 7, 7, 0xFFFF0000)
			elseif (tile_type == 0x6300) or (tile_type == 0x6304) or (tile_type == 0x6308) then
				view_win.DrawPolygon({{x_tile+4,y_tile+3},{x_tile+7,y_tile},{x_tile+7,y_tile+7},{x_tile+4,y_tile+4}}, 0xFFFF0000)
			elseif (tile_type == 0x630C) then
				view_win.DrawPolygon({{x_tile,y_tile},{x_tile+3,y_tile+3},{x_tile+3,y_tile+4},{x_tile,y_tile+7}}, 0xFFFF0000)
			elseif (tile_type == 0x0B00) or (tile_type == 0x1000) then
				view_win.DrawPolygon({{x_tile +7,y_tile},{x_tile +7,y_tile +7},{x_tile,y_tile +7}}, 0xFFFF0000)
			elseif (tile_type == 0x0B04) then
				view_win.DrawPolygon({{x_tile,y_tile},{x_tile,y_tile +7},{x_tile +7,y_tile +7}}, 0xFFFF0000)
			elseif (tile_type == 0x0B08) then
				view_win.DrawPolygon({{x_tile,y_tile},{x_tile +7,y_tile},{x_tile +7,y_tile +7}}, 0xFFFF0000)
			elseif (tile_type == 0x0B0C) or (tile_type == 0x100C) then
				view_win.DrawPolygon({{x_tile,y_tile},{x_tile +7,y_tile},{x_tile,y_tile +7}}, 0xFFFF0000)
			elseif (tile_type == 0x7200) then
				view_win.DrawPolygon({{x_tile +7,y_tile +4},{x_tile +7,y_tile +7},{x_tile,y_tile +7}}, 0xFFFF0000)
			elseif (tile_type == 0x7204) then
				view_win.DrawPolygon({{x_tile,y_tile +4},{x_tile +7,y_tile +7},{x_tile,y_tile +7}}, 0xFFFF0000)
			elseif (tile_type == 0x7208) then
				view_win.DrawPolygon({{x_tile,y_tile},{x_tile +7,y_tile},{x_tile +7,y_tile +3}}, 0xFFFF0000)
			elseif (tile_type == 0x720C) then
				view_win.DrawPolygon({{x_tile,y_tile},{x_tile +7,y_tile},{x_tile,y_tile +3}}, 0xFFFF0000)
			elseif (tile_type == 0x7300) or (tile_type == 0x4200) then
				view_win.DrawPolygon({{x_tile,y_tile +3},{x_tile +7,y_tile},{x_tile +7,y_tile +7},{x_tile,y_tile +7}}, 0xFFFF0000)
			elseif (tile_type == 0x7304) or (tile_type == 0x4204) then
				view_win.DrawPolygon({{x_tile,y_tile},{x_tile +7,y_tile +3},{x_tile +7,y_tile +7},{x_tile,y_tile +7}}, 0xFFFF0000)
			elseif (tile_type == 0x7308) or (tile_type == 0x4208) then
				view_win.DrawPolygon({{x_tile,y_tile},{x_tile +7,y_tile},{x_tile +7,y_tile +7},{x_tile,y_tile +4}}, 0xFFFF0000)
			elseif (tile_type == 0x730C) or (tile_type == 0x420C) then
				view_win.DrawPolygon({{x_tile,y_tile},{x_tile +7,y_tile},{x_tile +7,y_tile +4},{x_tile,y_tile +7}}, 0xFFFF0000)
			elseif (tile_type == 0x3D00) or (tile_type == 0x360C) then
				view_win.DrawPolygon({{x_tile +3,y_tile},{x_tile +7,y_tile},{x_tile +7,y_tile +7},{x_tile,y_tile +7}}, 0xFFFF0000)
			elseif (tile_type == 0x3D04) or (tile_type == 0x3608) then
				view_win.DrawPolygon({{x_tile,y_tile},{x_tile +4,y_tile},{x_tile +7,y_tile +7},{x_tile,y_tile +7}}, 0xFFFF0000)
			elseif (tile_type == 0x3D08) or (tile_type == 0x3604) then
				view_win.DrawPolygon({{x_tile,y_tile},{x_tile +7,y_tile},{x_tile +7,y_tile +7},{x_tile +3,y_tile +7}}, 0xFFFF0000)
			elseif (tile_type == 0x3D0C) or (tile_type == 0x3600) then
				view_win.DrawPolygon({{x_tile,y_tile},{x_tile +7,y_tile},{x_tile +4,y_tile +7},{x_tile,y_tile +7}}, 0xFFFF0000)
			elseif (tile_type == 0x1D00) or (tile_type == 0x3400) then
				view_win.DrawPolygon({{x_tile +7,y_tile},{x_tile +7,y_tile +7},{x_tile +4,y_tile +7}}, 0xFFFF0000)
			elseif (tile_type == 0x1D04) then
				view_win.DrawPolygon({{x_tile,y_tile},{x_tile +3,y_tile +7},{x_tile,y_tile +7}}, 0xFFFF0000)
			elseif (tile_type == 0x1D08) then
				view_win.DrawPolygon({{x_tile +4,y_tile},{x_tile +7,y_tile},{x_tile +7,y_tile +7}}, 0xFFFF0000)
			elseif (tile_type == 0x1D0C) then
				view_win.DrawPolygon({{x_tile,y_tile},{x_tile +3,y_tile},{x_tile,y_tile +7}}, 0xFFFF0000)
			elseif (tile_type == 0x0900) or (tile_type == 0x0904) then
				view_win.DrawRectangle(x_tile, y_tile +4, 7, 3, 0xFFFF0000)
			elseif (tile_type == 0x6D00) or (tile_type == 0x6D04) then
				view_win.DrawRectangle(x_tile, y_tile, 7, 3, 0xFFFF0000)
			elseif (tile_type == 0x6408) then
				view_win.DrawPolygon({{x_tile,y_tile},{x_tile+4,y_tile+4},{x_tile+7,y_tile+4},{x_tile+7,y_tile+7},{x_tile,y_tile+7}}, 0xFFFF0000)
			elseif (tile_type == 0x640C) then
				view_win.DrawPolygon({{x_tile,y_tile+4},{x_tile+3,y_tile+4},{x_tile+7,y_tile},{x_tile+7,y_tile+7},{x_tile,y_tile+7}}, 0xFFFF0000)
			elseif (tile_type == 0x6508) then
				view_win.DrawPolygon({{x_tile,y_tile},{x_tile+7,y_tile},{x_tile+7,y_tile+3},{x_tile+3,y_tile+3}}, 0xFFFF0000)
			elseif (tile_type == 0x650C) then
				view_win.DrawPolygon({{x_tile,y_tile},{x_tile+7,y_tile},{x_tile+4,y_tile+3},{x_tile,y_tile+3}}, 0xFFFF0000)
			elseif (tile_type == 0x2600) or (tile_type == 0x0904) then
				view_win.DrawRectangle(x_tile +4, y_tile, 3, 7, 0xFFFF0000)
			elseif (tile_type == 0x2F00) or (tile_type == 0x6D04) then
				view_win.DrawRectangle(x_tile, y_tile, 3, 7, 0xFFFF0000)
			elseif (tile_type == 0x6704) then
				view_win.DrawPolygon({{x_tile,y_tile},{x_tile+7,y_tile},{x_tile+7,y_tile+7},{x_tile+4,y_tile+7},{x_tile+4,y_tile+4}}, 0xFFFF0000)
			elseif (tile_type == 0x670C) then
				view_win.DrawPolygon({{x_tile+4,y_tile},{x_tile+7,y_tile},{x_tile+7,y_tile+7},{x_tile,y_tile+7},{x_tile+4,y_tile+3}}, 0xFFFF0000)
			elseif (tile_type == 0x6604) then
				view_win.DrawPolygon({{x_tile,y_tile},{x_tile+3,y_tile+3},{x_tile+3,y_tile+7},{x_tile,y_tile+7}}, 0xFFFF0000)
			elseif (tile_type == 0x660C) then
				view_win.DrawPolygon({{x_tile,y_tile},{x_tile+3,y_tile},{x_tile+3,y_tile+4},{x_tile,y_tile+7}}, 0xFFFF0000)
			elseif (tile_type == 0x6700) then
				view_win.DrawPolygon({{x_tile,y_tile},{x_tile+7,y_tile},{x_tile+3,y_tile+4},{x_tile+3,y_tile+7},{x_tile,y_tile+7}}, 0xFFFF0000)
			elseif (tile_type == 0x6708) then
				view_win.DrawPolygon({{x_tile,y_tile},{x_tile+3,y_tile},{x_tile+3,y_tile+3},{x_tile+7,y_tile+7},{x_tile,y_tile+7}}, 0xFFFF0000)
			elseif (tile_type == 0x6600) then
				view_win.DrawPolygon({{x_tile+7,y_tile},{x_tile+7,y_tile+7},{x_tile+4,y_tile+7},{x_tile+4,y_tile+3}}, 0xFFFF0000)
			elseif (tile_type == 0x6608) then
				view_win.DrawPolygon({{x_tile+4,y_tile},{x_tile+7,y_tile},{x_tile+7,y_tile+7},{x_tile+4,y_tile+4}}, 0xFFFF0000)
			elseif (tile_type == 0x6400) then
				view_win.DrawPolygon({{x_tile,y_tile},{x_tile+7,y_tile},{x_tile+7,y_tile+3},{x_tile+4,y_tile+3},{x_tile,y_tile+7}}, 0xFFFF0000)
			elseif (tile_type == 0x6404) then
				view_win.DrawPolygon({{x_tile,y_tile},{x_tile+7,y_tile},{x_tile+7,y_tile+7},{x_tile+3,y_tile+3},{x_tile,y_tile+3}}, 0xFFFF0000)
			elseif (tile_type == 0x6500) then
				view_win.DrawPolygon({{x_tile,y_tile+7},{x_tile+4,y_tile+3},{x_tile+7,y_tile+3},{x_tile+7,y_tile+7}}, 0xFFFF0000)
			elseif (tile_type == 0x6504) then
				view_win.DrawPolygon({{x_tile,y_tile+3},{x_tile+3,y_tile+3},{x_tile+7,y_tile+7},{x_tile,y_tile+7}}, 0xFFFF0000)
			elseif (tile_type == 0xFB00) or (tile_type == 0xFB04) or (tile_type == 0xFB08) or (tile_type == 0xFB0C) or (tile_type == 0xFD00) or (tile_type == 0xFD04) or (tile_type == 0xFD08) or (tile_type == 0xFD0C) or (tile_type == 0xEA00) or (tile_type == 0xEA04) or (tile_type == 0xEA08) or (tile_type == 0xEA0C) or (tile_type == 0xED00) or (tile_type == 0xED04) or (tile_type == 0xED08) or (tile_type == 0xED0C) then
				view_win.DrawRectangle(x_tile, y_tile, 7, 7, 0xFF4040FF)
			elseif (tile_type == 0xFE00) or (tile_type == 0xFE04) or (tile_type == 0xFE08) or (tile_type == 0xFE0C) or (tile_type == 0xFF00) or (tile_type == 0xFF04) or (tile_type == 0xFF08) or (tile_type == 0xFF0C) then
				view_win.DrawRectangle(x_tile, y_tile, 7, 7, 0xFFD0D000)
			end
		end
	end
	
	view_win.DrawAxis(127,127,6)
	view_win.Refresh()
	
	emu.frameadvance()
end