Post subject: emu.yield() and rendering issues?
Joined: 2/5/2014
Posts: 28
I'm trying to figure out how to properly pause the game while still drawing things to the screen and I'm not having much luck, maybe it's something I'm missing? The idea is this... scan the inputs, when a button is pressed pause the game and bring up a menu. I just can't seem to get things working right. emu.yield() doesn't seem to do anything by itself. I have to include a emu.pause() as well. While paused I can certainly read inputs and text "sort of" updates, but nothing else. I can't render images, and the last frame of the game doesn't seem to render, making any sort of changed text blurr together with the text from the last frame and whatever is left of the gameplay image. I've tried all kinds of stuff, client.paint() to get the game to re-render and maybe show my images, gui.ClearGraphics() to remove the old text ect... nothing works. I also looked at the registers listed in the docs, but unless I misunderstood one is before anything, even the game gets rendered (too soon) and one is after the frame is rendered (too late). Can somebody post an example please? Here is my rather cluttered (from trying various stuff) test script btw...
x=0

while true do
		x=x+1 --Test rendering while paused via constantly changing text
		if x>=100 then x =0 end;
			JOY1=joypad.getimmediate();
			
			if JOY1["P1 Start"]~=false and JOY1["P1 Select"]~=false then
				os.exit();
			end
			gui.text(10,10,"Hello World!");
			gui.text(10,40,x);
			if JOY1["P1 Start"]==true then
				gui.clearGraphics()
				client.paint()
				gui.drawImage("nes.png" , 0 , 8);
				gui.text(10,30,"True");
				client.paint()
				emu.yield()
				client.pause()
				--gui.clearGraphics()
			else
				client.unpause()
				gui.text(10,30,"False");
				emu.frameadvance()
			end
		
	end;