Pause management

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
seventh
Posts: 11
Joined: Sat Jan 21, 2006 2:10 am

Pause management

Post by seventh »

Hi,

I'm trying to manage correctly a pause in my tetris-like game. The issue I have is that I try with <pspctrl.h> to manage the PSP_CTRL_HOME keypress, and in fact this cannot be right as anyone can exit the "do you want to exit ?" screen by simply answering "no" to this question.

Furthermore, this seems to me very complicated and not secure to try to mimic what can be done on this screen.

How do everybody does ? Isn't there a simple way ? A signal or something like this...

Thank you,

7th
Art
Posts: 642
Joined: Wed Nov 09, 2005 8:01 am

Post by Art »

Well this question makes little sense to me.

If you can't pause a game, I don't see how you can write it at all.
If the issue is with the HOME button, it's the same as any other button
in kernal mode.

Is it a problem that you press HOME and the game keeps running while
you are on the exit screen?
Why not ditch the exit callback and handle the exit yourself?
If not actually, then potentially.
seventh
Posts: 11
Joined: Sat Jan 21, 2006 2:10 am

Post by seventh »

This is it, the game keeps running while being on the exit screen.

I use the usual piece of code with the callback_thread that registers an exit callback that will be called if user says yes to the "do you want to exit?" question. This exit callback changes a global loop control so that my program can exit normally.

With this piece of code, I don't see where I can graft a pause. I have to admit that I rarely use callbacks and that I don't all the events for which I can register a callback. Maybe there is a specific one for this particuliar screen and behavior ?
User avatar
Raphael
Posts: 646
Joined: Tue Jan 17, 2006 4:54 pm
Location: Germany
Contact:

Post by Raphael »

The question is, why do you want the game to pause when the user presses the HOME button? The HOME button isn't intended as a "PAUSE", so the user should only press it if he really is about to exit the game. Actually, I've yet to find a commercial game that pauses gameplay while the home button screen is active.
If you want a PAUSE button, use select or start button and implement your own PAUSE screen.
<Don't push the river, it flows.>
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki

Alexander Berl
seventh
Posts: 11
Joined: Sat Jan 21, 2006 2:10 am

Post by seventh »

Raphael : I would agree with you if there was not the confirmation screen. So if one presses the HOME button, okay the program exits, that is what the user wants.
But the user can confirm his choice, so during the time he's taking a decision, I find it unfair that the game continues to evolve.

I implemented a pause with the SELECT button, it works well. I just want to force the pause when the HOME button is pressed. An issue is raised when I exit the confirmation screen by selecting "no" instead of pressing HOME again.

I read the http://forums.ps2dev.org/viewtopic.php?t=8818 thread, and in fact I don't see how the proposed schema could work.

But maybe you are right, no commercial game proposes to force pause mode when HOME button is pressed ; by the way, I don't think it's a feature, it's just that (for the moment) I don't see any clean way to do so.
Art
Posts: 642
Joined: Wed Nov 09, 2005 8:01 am

Post by Art »

One solution is to delete the exit callback, then use the HOME button yourself.
I'd have a still screen of the game paused with the "Do you want to exit?"
prompt printed over it. Problem is I think that is only possible in kernel mode.
If not actually, then potentially.
Art
Posts: 642
Joined: Wed Nov 09, 2005 8:01 am

Post by Art »

I read the http://forums.ps2dev.org/viewtopic.php?t=8818 thread, and in fact I don't see how the proposed schema could work.
It could work.
Although messy, it could also be used to solve your problem.

You could use GetPixelColour to test one pixel on the screen
that you know will turn grey when the HOME button is pressed.

I didn't bother with that because after I posted that thread,
I was given a proper way to read and set volume.
If not actually, then potentially.
seventh
Posts: 11
Joined: Sat Jan 21, 2006 2:10 am

Post by seventh »

For the callback thread, I don't see how it can work : to activate the thread, you have to detect that the HOME button is pressed : not reliable. Furthermore, even if you have a reliable way to detect that the exit screen is displayed, what is the point of doing your treatment in the callback thread, and not the main thread ?

In which library is provided your GetPixelColour function ? Because I supposed that in fact the exit screen was displayed through the framebuffer, and so tried to check the video memory pointer value, and it does not change wether the exit screen is displayed or not.

The only thing I finally found is to force pause when entering the exit screen, but not automatically restart the game when HOME is pressed once more, or that the user says no.
User avatar
Raphael
Posts: 646
Joined: Tue Jan 17, 2006 4:54 pm
Location: Germany
Contact:

Post by Raphael »

seventh wrote:Raphael : I would agree with you if there was not the confirmation screen. So if one presses the HOME button, okay the program exits, that is what the user wants.
But the user can confirm his choice, so during the time he's taking a decision, I find it unfair that the game continues to evolve.
I don't find it unfair, because the home button isn't supposed to be a "kind-off" pause button. If the user is unsure about his decision, he should open up the in-game pause screen before pressing the HOME button. And if he pushes the HOME button by accident (which never ever happened to me once in the two years I have my PSP), then it's bad luck.
As said, no commercial game I found till today handles this case, so I don't really see any reason why to bother. Anyone and their grandma should know by now that the HOME button normally doesn't pause the 'common' game.
<Don't push the river, it flows.>
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki

Alexander Berl
Art
Posts: 642
Joined: Wed Nov 09, 2005 8:01 am

Post by Art »

I think it should, although I tested Pinball and found out you're right.

Otherwise there's no reason for a "Yes <> No" requester,
so there's a bit of an inconsistency.
If it's not going to pause, I think all games should just exit without the request.

Most of my homebrew actually just exits with one press of the HOME button,
so I obviously prefer it that way, but I don't use a meaningless requester.

Surely you can look at the content of VRAM for every frame?
In a game like Tetris you should have a thousand years CPU time
to spare between bricks falling.

I think X-Flash was the best exit with HOME button implementation
I've seen, if I do say so myself, though I've yet to use it in another program.
If not actually, then potentially.
User avatar
Raphael
Posts: 646
Joined: Tue Jan 17, 2006 4:54 pm
Location: Germany
Contact:

Post by Raphael »

Art wrote:I think it should, although I tested Pinball and found out you're right.

Otherwise there's no reason for a "Yes <> No" requester,
so there's a bit of an inconsistency.
If it's not going to pause, I think all games should just exit without the request.
Well, the HOME button shouldn't be considered the main exit function of a game IMO - more like a soft reset button on a PC. It's more like Sonys way to provide a consistent function to be able to quit games at any place - hence why there's no option for non-kernel mode applications to poll or intercept the HOME button to make custom use of it. Anyway, if it was intended by Sony that games should pause during the home button callback, there would be such functionality in the SDK and the official developers would have used it. As it seems there isn't.

Regarding why Sony put the yes/no choice in there - well - maybe because they feared that unintentional HOME button presses could cause lots of mad users with lost game states, or maybe because they just handle the user as a "retarded fish" (like MS does too) and verify any input. You'd have to ask them for a definite answer.
<Don't push the river, it flows.>
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki

Alexander Berl
Art
Posts: 642
Joined: Wed Nov 09, 2005 8:01 am

Post by Art »

Ah yes you are right of course... you elicit the fact that commercial games
handle their own program exits. I do the same thing, and just chose to use
the HOME button for that.
Many homebrew programmers use the Sony exit callback as their only
means of program exit, probably because they were programmed to do so
by SDK samples, so the idea sticks.

Still on a drive I thought, if seventh is able to detect the first HOME button press,
that is the time to set the flag "pause" to 1, but keep the game going as normal,
but when any button other than Dpad left is pressed again, time reverses until the game
position the pause flag was set is reached, and game resumes in forward motion.
There are still options if you reeeeeely want to stand Sony up.
If not actually, then potentially.
User avatar
Raphael
Posts: 646
Joined: Tue Jan 17, 2006 4:54 pm
Location: Germany
Contact:

Post by Raphael »

I just had a peek through sceImpose again (for some other reason) and hit the sceImposeGetHomePopup function once more. Isn't that function returning the current state of the Home button popup (off/on)? If so, that would be the solution to the problem. Not sure if that function is available in user mode though, but if I remember correctly it existed in the user mode stubs of sceImpose, so it should.
<Don't push the river, it flows.>
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki

Alexander Berl
sakya
Posts: 190
Joined: Fri Apr 28, 2006 5:48 pm
Contact:

Post by sakya »

Hi! :)

Here there's a thread on sceImposeGetHomePopup:
http://forums.ps2dev.org/viewtopic.php?t=9225

I found no way to know if the user is viewing the exit screen, but I was able to disable it (with sceImposeSetHomePopup that seems to work fine in user mode) and then manage the home button in my code.

Ciaooo
Sakya
PSPZorZ
Posts: 1
Joined: Sat Dec 29, 2007 12:47 am

Post by PSPZorZ »

One thing you guys forgot to mention is that the home button isn't ONLY used for exiting. Most of the time I press it, it's not to exit, but to check the time, battery life, or see what my volume's set to. That's a good reason for the confirmation screen when "home" is pressed.

To original poster: Why does it even matter if the game is paused when the player selects "No"? There are 2 possibilities: 1) Player presses Home (game is paused) and presses Home again to exit the screen (game is unpaused), and continues to play. 2) Player pressed Home (pauses game) and exits Home screen through other means (pressing O button or selecting "No") and is returned to the game at a paused screen. You could simply make sure that, when paused, the screen says "Paused" in the middle of it, so the user knows to press Start (or another button of your choosing) to unpause it. I don't, however, suggest you implement a custom exit screen... I, along with many other people, have grown accustomed to that screen :).
seventh
Posts: 11
Joined: Sat Jan 21, 2006 2:10 am

Post by seventh »

There is nothing armful in getting back to pause mode when exiting in a way or another the "exit screen", it is just inelegant.

More inelegant is to have to detect by any means that this exit screen is currently displayed. Theoretically, it is not because I poll the status of the HOME button that I'm sure I will always detect all appearances of the exit screen.

But, as no other mean seems to exist, I have to go this way...
Art
Posts: 642
Joined: Wed Nov 09, 2005 8:01 am

Post by Art »

With this thread in mind:
http://forums.ps2dev.org/viewtopic.php?t=9679

You can have a game pause automatically when the exit popup is showing

Code: Select all

			if&#40;pad.Buttons & PSP_CTRL_HOME&#41; &#123;
			gamepause = 1;
			&#125; else &#123;
			gamepause = 0;
			&#125;
I tried it, it works well:
http://rapidshare.com/files/88502202/Po ... e.zip.html

Cheers, Art.
If not actually, then potentially.
Post Reply