User File #40514324134190870

Upload All User Files

#40514324134190870 - GB Fortified Zone Lua script

Fortified Zone (USA, Europe).lua
1009 downloads
Uploaded 7/21/2017 1:21 PM by TASeditor (see all 188)
For BizHawk 1.12.0.
Map collision and TAStudio coloring.
memory.usememorydomain("WRAM")
X = 0
Xsub = 0
Y = 0
Ysub = 0

AirTable = {}
maxAir = 0

BulletsGirl = {}
BulletsGuy = {}

maxBullGirl = 0
maxBullGuy = 0

Canvas = gui.createcanvas(513, 513)

function Draw(index, column)

	local entry = AirTable[index]
	maxAir = maxAir + 1
	
	if (entry == 1) and (column == "A")
	then return 0xA8DDFF
	end
	
	local entryGirl = BulletsGirl[index]
	maxBullGirl = maxBullGirl + 1
	local entryGuy = BulletsGuy[index]
	maxBullGuy = maxBullGuy + 1
		if (entryGirl == 2) and (entryGuy == 5) and (column == "B")
	then return 0xCA82FF
	end
	
	if (entryGirl == 2) and (column == "B")
	then return 0xFFBCEB
	end
	
	if (entryGuy == 5) and (column == "B")
	then return 0xBFD4FF
	end
	


end

function CanvasDrawing()

	Canvas.Clear("white");
	
	for i = 0, 0xF, 1 do
		
		for j = 0, 0xF, 1 do
		
			
			local tile = memory.read_u8((0x1200+0x10*i+j))
			local form = tile % 0x10
			local property = tile - (tile % 0x10)		
	
			if property == 0x20
			then color = 0xFFBBBBBB
			elseif property >= 0x30 and property <= 0x70
			then color = 0xFF006666
			elseif property == 0x80
			then color = 0xFFFFFFFF
			elseif property == 0xA0
			then color = 0xFF660000
			elseif property == 0xB0
			then color = 0xFF777777
			elseif property == 0xC0
			then color = 0xFF000000
			else color = 0xFF444444
			end

			if form == 0x00
			then 
			elseif form == 0x01
			then Canvas.DrawRectangle(0+32*j, 0+32*i, 16, 16, color, color)
			elseif form == 0x02
			then Canvas.DrawRectangle(16+32*j, 0+32*i, 16, 16, color, color)
			elseif form == 0x03
			then Canvas.DrawRectangle(0+32*j, 0+32*i, 32, 16, color, color)
			elseif form == 0x04
			then Canvas.DrawRectangle(0+32*j, 16+32*i, 16, 16, color, color)
			elseif form == 0x05
			then Canvas.DrawRectangle(0+32*j, 0+32*i, 16, 32, color, color)
			elseif form == 0x06
			then Canvas.DrawRectangle(16+32*j, 0+32*i, 16, 16, color, color); Canvas.DrawRectangle(0+32*j, 16+32*i, 16, 16, color, color)
			elseif form == 0x07
			then Canvas.DrawRectangle(0+32*j, 0+32*i, 32, 16, color, color); Canvas.DrawRectangle(0+32*j, 16+32*i, 16, 16, color, color)
			elseif form == 0x08
			then Canvas.DrawRectangle(16+32*j, 16+32*i, 16, 16, color, color)
			elseif form == 0x09
			then Canvas.DrawRectangle(0+32*j, 0+32*i, 16, 16, color, color); Canvas.DrawRectangle(16+32*j, 16+32*i, 16, 16, color, color)
			elseif form == 0x0A
			then Canvas.DrawRectangle(16+32*j, 0+32*i, 16, 32, color, color)
			elseif form == 0x0B
			then Canvas.DrawRectangle(0+32*j, 0+32*i, 32, 16, color, color); Canvas.DrawRectangle(16+32*j, 16+32*i, 16, 16, color, color)
			elseif form == 0x0C
			then Canvas.DrawRectangle(0+32*j, 16+32*i, 32, 16, color, color);
			elseif form == 0x0D
			then Canvas.DrawRectangle(0+32*j, 0+32*i, 16, 32, color, color); Canvas.DrawRectangle(16+32*j, 16+32*i, 16, 16, color, color)
			elseif form == 0x0E
			then Canvas.DrawRectangle(16+32*j, 0+32*i, 16, 32, color, color); Canvas.DrawRectangle(0+32*j, 16+32*i, 16, 16, color, color)
			elseif form == 0x0F
			then Canvas.DrawRectangle(0+32*j, 0+32*i, 32, 32, color, color)
			end
		end
	end
	
	
	for i = 0, 0x1F, 1 do
	
		--Buttons           0100 
						
		YSpeed = memory.read_u16_be(0x0101+0x20*i) 
		Y = memory.read_u8(0x0103+0x20*i) 
		YSubpixel = memory.read_u8(0x0104+0x20*i) 
						
		XSpeed = memory.read_u16_be(0x0105+0x20*i) 
		X = memory.read_u8(0x0107+0x20*i) 
		XSubpixel = memory.read_u8(0x0108+0x20*i) 
						
		Health = memory.read_u8(0x010D+0x20*i) 				
		WeaponA = memory.read_u8(0x010E+0x20*i) 
		WeaponB = memory.read_u8(0x010F+0x20*i) 
						
		height_ptr = memory.read_u16_le(0x0116+0x20*i)
		width_ptr = memory.read_u16_le(0x0118+0x20*i)
		
		
		--print(string.format("%d", YSpeed))
						
		Room = memory.read_u8(0x011C+0x20*i) 
		--Animation         011D 
		--Animation	      011E 
		FacingDirection = memory.read_u8(0x011F+0x20*i) 
		
		
		
		if Room ~= 255
		then 
		
		--h = memory.read_u8(height_ptr, "ROM")
		--w = memory.read_u8(width_ptr, "ROM")
		
		Canvas.DrawText(X*2, Y*2, string.format("%d:%d\n%d:%d\n%d", X, XSubpixel, Y, YSubpixel, Health), 0xFF0000FF, 10, "Arial")
		gui.pixelText(X, Y, ""..Health, 0xFFF0FFFF, 0xAA000000, "gens")
		Canvas.DrawRectangle(X*2, Y*2, 1 , 1)
		
		end
	
	end

	--Projectiles
	for i = 0, 6, 1 do
		
		y1 = memory.read_u8(0x0D00+4*i)
		y2 = memory.read_u8(0x0D01+4*i)
		x1 = memory.read_u8(0x0D02+4*i)
		x2 = memory.read_u8(0x0D03+4*i)
			
		--Canvas.DrawText(x1, y1, "asdf")
			
		--Canvas.DrawRectangle(x1*2, y1*2, (x1-x2)*2, (y1-y2)*2)
	end
	
	--Player
	Canvas.DrawRectangle(memory.read_u8(0x1426)*2, memory.read_u8(0x1425)*2, 1,1)
	--Canvas.DrawRectangle(X_player*2, Y_player*2+32, 32,32, "red")
	
	Canvas.Refresh();

end

function Close()

	forms.destroyall()
	
end

--event.onexit(Close)
tastudio.onqueryitembg(Draw)

while true do

	local Y_guy = memory.read_u8(0x0103)
	local Ysub_guy = memory.read_u8(0x0104)
	
	local X_guy = memory.read_u8(0x0107)
	local Xsub_guy = memory.read_u8(0x0108)
	
	local Y_girl = memory.read_u8(0x0123)
	local Ysub_girl = memory.read_u8(0x0124)
	
	local X_girl = memory.read_u8(0x0127)
	local Xsub_girl = memory.read_u8(0x0128)
	
	frame = emu.framecount()

	if memory.read_u8(0x011C) == 255
	then Y_player = Y_girl
		 Ysub_player = Ysub_girl
		 X_player = X_girl
		 Xsub_player = Xsub_girl 
		 
	elseif memory.read_u8(0x013C) == 255
		then Y_player = Y_guy
		     Ysub_player = Ysub_guy
		     X_player = X_guy
		     Xsub_player = Xsub_guy
	end
	
	if memory.read_u8(0x012E) == 1
	then AirTable[frame-1] = 1
	else AirTable[frame-1] = 0
	end
	
	BulletsGirl[frame-1] = 0
	if memory.read_u8(0x21C) ~= 255 then BulletsGirl[frame-1] = BulletsGirl[frame-1] + 1 end	
	if memory.read_u8(0x23C) ~= 255 then BulletsGirl[frame-1] = BulletsGirl[frame-1] + 1 end
	
	BulletsGuy[frame-1] = 0
	if memory.read_u8(0x25C) ~= 255 then BulletsGuy[frame-1] = BulletsGuy[frame-1] + 1 end	
	if memory.read_u8(0x27C) ~= 255 then BulletsGuy[frame-1] = BulletsGuy[frame-1] + 1 end	
	if memory.read_u8(0x29C) ~= 255 then BulletsGuy[frame-1] = BulletsGuy[frame-1] + 1 end	
	if memory.read_u8(0x2BC) ~= 255 then BulletsGuy[frame-1] = BulletsGuy[frame-1] + 1 end	
	if memory.read_u8(0x2DC) ~= 255 then BulletsGuy[frame-1] = BulletsGuy[frame-1] + 1 end	
	
	gui.drawText(0, 30,"X:"..X_player..":"..Xsub_player.." ", 0xFFFFFFFF, 0x99990000)
	gui.drawText(0, 43,"Y:"..Y_player..":"..Ysub_player.." ", 0xFFFFFFFF, 0x99009900)
	
	--gui.pixelText(150, 0, ""..BulletsGirl[frame-1].."", 0x88FFFFFF, 0x88CA82FF)
	--gui.pixelText(155, 0, ""..BulletsGuy[frame-1].."", 0x88FFFFFF, 0x88BFD4FF)
	
	
	

	
	CanvasDrawing()
	
	-- for i = 0, 0x9, 1 do
		
		-- for j = 0, 0x9, 1 do
		
			
			-- tile = memory.read_u8((0x1200+0x10*i+j))
			
			-- property = tile - (tile % 0x10)
		
			--print(tostring(string.format("%X", (0x1200+0x10*i+j))))
		
			-- if tile == 0x00
			-- then
			-- elseif tile == 0x04
			-- then gui.drawRectangle(0+16*j, 8+16*i, 8, 8)
			-- elseif tile == 0x05
			-- then gui.drawRectangle(0+16*j, 0+16*i, 8, 16)
			-- elseif tile == 0x07 
			-- then gui.drawPolygon({{0+16*j,0+16*i}, {16+16*j, 0+16*i}, {16+16*j, 8+16*i}, {8+16*j, 8+16*i}, {8+16*j, 16+16*i}, {0+16*j, 16+16*i}})
			-- elseif tile == 0x0A
			-- then gui.drawRectangle(8+16*j, 0+16*i, 8, 16)
			-- elseif tile == 0x0B
			-- then gui.drawPolygon({{0+16*j,0+16*i}, {16+16*j, 0+16*i}, {16+16*j, 16+16*i}, {8+16*j, 16+16*i}, {8+16*j, 8+16*i}, {0+16*j, 8+16*i}})
			-- elseif tile == 0x0C
			-- then gui.drawRectangle(0+16*j, 8+16*i, 16, 8)
			-- elseif tile == 0x0D
			-- then gui.drawPolygon({{0+16*j,0+16*i}, {8+16*j, 0+16*i}, {8+16*j, 8+16*i}, {16+16*j, 8+16*i}, {16+16*j, 16+16*i}, {0+16*j, 16+16*i}})
			-- elseif tile == 0x0E
			-- then gui.drawPolygon({{8+16*j,0+16*i}, {16+16*j, 0+16*i}, {16+16*j, 16+16*i}, {0+16*j, 16+16*i}, {0+16*j, 8+16*i}, {8+16*j, 8+16*i}})
			-- elseif tile == 0x0F 
			-- then gui.drawRectangle(0+16*j, 0+16*i, 16, 16)		
			-- elseif tile == 0x03
			-- then gui.drawRectangle(0+16*j, 0+16*i, 16, 8)
			-- elseif tile == 0x01
			-- then gui.drawRectangle(0+16*j, 0+16*i, 8, 8)
			-- elseif tile == 0x02
			-- then gui.drawRectangle(8+16*j, 0+16*i, 8, 8)
			-- elseif tile == 0x06
			-- then gui.drawPolygon({{8+16*j, 0+16*i}, {16+16*j, 0+16*i}, {16+16*j, 8+16*i}, {0+16*j, 8+16*i}, {0+16*j, 16+16*i}, {8+16*j, 16+16*i}})
			-- elseif tile == 0x08
			-- then gui.drawRectangle(8+16*j, 8+16*i, 8, 8)
			-- elseif tile == 0x09
			-- then gui.drawPolygon({{0+16*j, 0+16*i}, {8+16*j, 0+16*i}, {8+16*j, 16+16*i}, {16+16*j, 16+16*i}, {16+16*j, 8+16*i}, {0+16*j, 8+16*i}})
			-- end
			
		-- end
	
	-- end
	-- 
	-- for k = 0, 20, 1 do
	-- gui.drawRectangle(memory.read_u8(0x107+0x20*k),memory.read_u8(0x103+0x20*k), 
						-- memory.read_u8(memory.read_u16_le(0x114+0x20*k), "System Bus"),
						-- memory.read_u8(memory.read_u16_le(0x118+0x20*k), "System Bus"))
						
	-- end
	--gui.drawText(0, 56, "R:"..(memory.read_u8(0x013C)))
	emu.frameadvance();
end