Skip to: Site menu | Main content


Welcome to PSP-Programming.com, a place for developers to get together.

Welcome to the forums. Here you can find other user tutorials as well as homebrew releases and the source code repository. You can also ask for help with your code here and post your own homebrew!

PSP-Programming.com Forums
February 08, 2012, 06:12:21 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

News: Join our IRC channel: ##psp-programming on freenode
Home Help Search Shop Login Register
Digg This!
Pages: [1]
Print
Author Topic: [C] Simple Menu Example  (Read 10085 times)
Flatmush
Has a normal user title
Administrator
Hero Member
*

Karma: +84/-26
Offline Offline

Posts: 1046
12906.27 points

View Inventory
Send Money to Flatmush

The Omniscient One


View Profile WWW
« on: February 13, 2007, 01:52:08 PM »

This wont interest most of you in the slightest, but as KIWI asked me how to do menus I made this very simple commented menu example.

If you are new to psp programming this is just slightly more advanced than hello world, and shows some good programming techniques.
« Last Edit: February 16, 2007, 01:48:28 PM by flatmush » Logged

Firmware History: 2.60 -> 2.71 -> 1.50 -> 3.03oe-c

I am nerdier than 66% of all people. Are you nerdier? Click here to find out!I am 62% loser. What about you? Click here to find out!NerdTests.com User Test: The Can I Run A Business Test.

Hehe I'm a "Hero Member" because I bought posts back when they were in the shop.

Creator of FlatEditPSP, funcLib and flAstro


Ryalla
harleyg
Hero Member
*****

Karma: +50/-12
Offline Offline

Posts: 813
9999999.99 points

View Inventory
Send Money to Ryalla


View Profile
« Reply #1 on: February 13, 2007, 02:41:30 PM »

I wonder what IWN changed in this post...?

EDIT
----
Looked through it and all I can say is that is a very clean menu. Surprised If you can't get that to work in your game, you shouldn't be programming.
« Last Edit: February 13, 2007, 02:45:42 PM by Ryalla » Logged
Insert_Witty_Name
Global Moderator
Hero Member
*

Karma: +149/-17
Offline Offline

Posts: 1602
1141.66 points

View Inventory
Send Money to Insert_Witty_Name

View Profile WWW
« Reply #2 on: February 13, 2007, 03:18:52 PM »

I just changed the title, adding the '[C]' part.
Logged

Coder formerly known as:

Check out my homebrew & C tutorials at http://insomniac.0x89.org
Last updated 6th Oct 06 - Tutorial 2 added.
Flatmush
Has a normal user title
Administrator
Hero Member
*

Karma: +84/-26
Offline Offline

Posts: 1046
12906.27 points

View Inventory
Send Money to Flatmush

The Omniscient One


View Profile WWW
« Reply #3 on: February 13, 2007, 05:32:55 PM »

Yeah the calling it crap part was me, because to be honest it is crap and I myself would never actually use it, but hopefully it will help someone else as well as kiwi, and leave one less question unanswered.
Logged

Firmware History: 2.60 -> 2.71 -> 1.50 -> 3.03oe-c

I am nerdier than 66% of all people. Are you nerdier? Click here to find out!I am 62% loser. What about you? Click here to find out!NerdTests.com User Test: The Can I Run A Business Test.

Hehe I'm a "Hero Member" because I bought posts back when they were in the shop.

Creator of FlatEditPSP, funcLib and flAstro
gohrum
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 2
197.14 points

View Inventory
Send Money to gohrum


View Profile
« Reply #4 on: November 13, 2007, 04:31:20 AM »

fuu, thanks a lot for this simple menu.
The best of all your code is the demo of how to include all the callbacks in one separate file Razz

And the menu aussi of course.
Thanks for all ^^
Logged
Flatmush
Has a normal user title
Administrator
Hero Member
*

Karma: +84/-26
Offline Offline

Posts: 1046
12906.27 points

View Inventory
Send Money to Flatmush

The Omniscient One


View Profile WWW
« Reply #5 on: November 13, 2007, 04:40:18 AM »

Thanks, but A_Nub did the callbacks in a separate file example.
Logged

Firmware History: 2.60 -> 2.71 -> 1.50 -> 3.03oe-c

I am nerdier than 66% of all people. Are you nerdier? Click here to find out!I am 62% loser. What about you? Click here to find out!NerdTests.com User Test: The Can I Run A Business Test.

Hehe I'm a "Hero Member" because I bought posts back when they were in the shop.

Creator of FlatEditPSP, funcLib and flAstro
A_Nub
gibbocool rules!
C/C++ Developer
Hero Member
*

Karma: +104/-28
Offline Offline

Posts: 912
3894.18 points

View Inventory
Send Money to A_Nub

Noob am I


View Profile WWW
« Reply #6 on: November 13, 2007, 10:10:47 AM »

Wink
Logged

Code:
      ____________________
 /---/   ---------------   \---\
/   O   |               |   ?   \
| O   O |               | ||  O |
|   O   |_______________|   X   |
\--- (#) () oo PSP oo ()()   ---/
    \-----------------------/
[/CENTER]
InsertWittyName: That's like saying because you wank with your right hank all the time, and one day you wank with your left, that you invented left handed wanking..
3DGURU
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 30
1512.62 points

View Inventory
Send Money to 3DGURU

View Profile
« Reply #7 on: November 22, 2007, 01:40:08 PM »

wow @_@ , if you have more of these share them with us  Razz
thanks , i have just made my first PBP today  Shocked
Logged
Flatmush
Has a normal user title
Administrator
Hero Member
*

Karma: +84/-26
Offline Offline

Posts: 1046
12906.27 points

View Inventory
Send Money to Flatmush

The Omniscient One


View Profile WWW
« Reply #8 on: November 23, 2007, 06:48:33 AM »

Well there's the simpleTimer one which follows on from this, it somewhere in the repository. If you really want more of these then you'll have to give me a topic to cover in the sample Smile
Logged

Firmware History: 2.60 -> 2.71 -> 1.50 -> 3.03oe-c

I am nerdier than 66% of all people. Are you nerdier? Click here to find out!I am 62% loser. What about you? Click here to find out!NerdTests.com User Test: The Can I Run A Business Test.

Hehe I'm a "Hero Member" because I bought posts back when they were in the shop.

Creator of FlatEditPSP, funcLib and flAstro
Vincent
Mudkips
C/C++ Developer
Hero Member
*

Karma: +76/-2
Offline Offline

Posts: 1384
9999999.99 points

View Inventory
Send Money to Vincent

Me and my 'Vette


View Profile WWW
« Reply #9 on: November 24, 2007, 10:52:49 PM »

Yeah, we pros tend to crank code like that out like nothin' lol. Razz Anyway, there's plenty of code existing out there in the forums too. The code you can find out there in the C/C++ section is a little random, but general. Just type in keywords, and you'll find some cool stuff.
Logged

Spiros
D.B. Cooper's accountant
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 10
742.76 points

View Inventory
Send Money to Spiros


View Profile
« Reply #10 on: February 09, 2009, 05:17:14 PM »

Hey,

if i wanted to skip a line between 2 menu items. how would i tell the tempMenuSelection(" -> ") variable to skip that line.

Code:
int tempMenuSelection = 14; // variable to store the current menu selection
while(gameState == GAMESTATE_MENU) { // loop while in menu mode

pspDebugScreenSetXY(0, 14); // set the text cursor back to the top left of the screen
pspDebugScreenPrintf("    Menu Item 1\n");
pspDebugScreenPrintf("    Menu Item 2\n");
pspDebugScreenPrintf("\n");
pspDebugScreenPrintf("    Menu Item 3\n");
pspDebugScreenPrintf("    Menu Item 4\n");
pspDebugScreenPrintf("    Exit\n");
pspDebugScreenSetXY(0, tempMenuSelection); // Move the text cursor to the selected item
pspDebugScreenPrintf(" ->"); // draw the selector

wait(5); // wait for 5/60ths of a second then menu
// is a reasonable speed.
                                                 
sceCtrlReadBufferPositive(&pad, 1); // check the input.
if(pad.Buttons & PSP_CTRL_CROSS) {  // if the cross button is pressed
switch(tempMenuSelection) {     // choose what to do depending on the menu number
case 14:
screen();
break;
case 18:
gameState = GAMESTATE_END; // change the game state to end, so that the loop exits.
break; // exit this case block otherwise the code below would also execute.
default:
// Do nothing
// The code to deal with an invalid menu selection can go here
break;
}
}

if(pad.Buttons & PSP_CTRL_UP)        // if the up button is pressed,
tempMenuSelection--;             // decrement the menu selection,
else if(pad.Buttons & PSP_CTRL_DOWN) // otherwise if the down button is pressed,
tempMenuSelection++;      // increment the menu selection.

if(tempMenuSelection > 18)       // if the menu selector is past the end of the menu,
tempMenuSelection = 14;      // move it to the beginning,
else if(tempMenuSelection < 14)  // otherwise if it is before the beginning,
tempMenuSelection = 18;      // move it to the end.

}

one of the things i tried was this:
Code:
if(pad.Buttons & PSP_CTRL_UP)        // if the up button is pressed,
tempMenuSelection--;             // decrement the menu selection,
else if(pad.Buttons & PSP_CTRL_DOWN) // otherwise if the down button is pressed,
tempMenuSelection++;      // increment the menu selection.

if(tempMenuSelection > 18)       // if the menu selector is past the end of the menu,
tempMenuSelection = 14;      // move it to the beginning,
else if(tempMenuSelection > 15)  // otherwise if it is before the beginning,
tempMenuSelection = 17;      // move it to the end.
else if(tempMenuSelection < 14)  // otherwise if it is before the beginning,
tempMenuSelection = 18;      // move it to the end.

}

but i can see why it doesnt work. i would just like to know how i could tell the "->" thing variable(not sure what to call it) to skip a certain line or case(also not sure which word to use).
Logged
Spiros
D.B. Cooper's accountant
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 10
742.76 points

View Inventory
Send Money to Spiros


View Profile
« Reply #11 on: February 09, 2009, 10:16:05 PM »

nevermind, after more playing around with the code i figured it out:
Code:
else if(tempMenuSelection >= 16 && tempMenuSelection < 17 && pad.Buttons & PSP_CTRL_DOWN)
tempMenuSelection = 17;
else if(tempMenuSelection >= 16 && tempMenuSelection < 17 && pad.Buttons & PSP_CTRL_UP)
tempMenuSelection = 15;
Logged
pentagram
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 42
2559.21 points

View Inventory
Send Money to pentagram

View Profile
« Reply #12 on: November 03, 2009, 06:21:33 AM »

reupload the arhive?
Logged
SoftHacker
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 6
373.49 points

View Inventory
Send Money to SoftHacker

View Profile
« Reply #13 on: February 14, 2011, 10:46:09 AM »

I can't download attachments  Evil or Very Mad
Can you re-up it anywhere else? Mediafire
Logged
Kronus980
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 42
2403.22 points

View Inventory
Send Money to Kronus980

View Profile
« Reply #14 on: May 10, 2011, 09:29:40 PM »

Says the attachment's not there Shocked I'd love a menu Razz Could someone re upload??
Logged

Maybe giving China the internet was a bad idea...   Confused
Pages: [1]
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.205 seconds with 38 queries.
Sister Sites: Guitar Hero 4   BrokeniTouch.com