function main(self)

	PLAY_AREA = ffi.cast("Rect*", 0x535840)[0]

	if self.State == 0 then
		self.Flags.AlwaysActive, self.DrawFlags.NoDraw = true, true
		if self.Smarts == 0 then
			self.State = 10
		elseif self.Smarts == 1 then
			self.State = 20
		end
	end
	-- Aspect ratio 16:9
	if self.State == 10 then
		if PLAY_AREA.Bottom > 486 or PLAY_AREA.Right ~= 863 then
			self.countTime = GetTime()
			self.State = 11
		end
	end
	if self.State == 11 then
		if GetTime() > self.countTime + 100 then
			ChangeResolution(864,486)
			self.State = 10
		end
	end
	-- Aspect ratio 4:3
	if self.State == 20 then
		if PLAY_AREA.Bottom > 480 or PLAY_AREA.Right ~= 639 then
			self.countTime = GetTime()
			self.State = 21
		end
	end
	if self.State == 21 then
		if GetTime() > self.countTime + 100 then
			ChangeResolution(640,480)
			self.State = 20
		end
	end
end
