popcornx
Newbie
Karma: +0/-0
Offline
Posts: 23
0.00 points View InventorySend Money to popcornx
|
 |
« Reply #30 on: June 04, 2006, 11:59:01 AM » |
|
Recursion is a function that calls itself. void rc(int num) { if (num > 3) { return; } else { num++; rc(num); } }
rc(1); it will run like this: call the function num=1; is num > 3? no increase by 1 call function num=2; is num > 3? no increase by 1 call function num=3; is num > 3? yes return to call #2 reutrn to call #1 oh yeah as my teacher would say "you must know recursion inorder to understand recursion"
|
|
|
|
|
Logged
|
|
|
|
|
|
faati
Full Member
 
Karma: +0/-1
Offline
Posts: 152
0.00 points View InventorySend Money to faati
|
 |
« Reply #31 on: June 04, 2006, 12:43:07 PM » |
|
I am finally done with all my errors and made my menu in single folder among with many other. but i got a single problem, when i press up and down the coler goes 3 down 3 up, it doesn't go 1 up, 1 down  here is my menu.c if someone can help  /* * This is the menu lib * This was created by ********, * Created at 15:39 , 4 Juni 2006. * If you want to add to this code plz send * me an email, xxFaaTixx@hotmail.com * */
//********************************************************************************** //Headers //********************************************************************************** #include <pspaudiolib.h> #include <pspdisplay.h> #include <pspkernel.h> #include <pspdebug.h> #include <pspaudio.h> #include <psppower.h> #include <pspctrl.h> #include <dirent.h> #include <psprtc.h> #include <string.h> #include <pspgu.h> #include <stdio.h> #include <png.h>
//********************************************************************************** //The Included Headers From Folder Common //********************************************************************************** #include "time.h" #include "mp3.h" #include "menu.h" #include "remote.h" #include "./Common_3/graphics.h" #include "./Common_3/mp3player.h" #include "./Common_3/callbacks.h" #include "./Common_3/framebuffer.h"
//********************************************************************************** //The Defines //********************************************************************************** #define setxy pspDebugScreenSetXY #define blit blitAlphaImageToScreen #define printf pspDebugScreenPrintf #define MAX(X, Y) ((X) > (Y) ? (X) : (Y)) #define RGB(r, g, b) ((r)|((g)<<8)|((b)<<16))
// int select_setting int Select_Setting = 1; //GLOBAL VARIABLES
//********************************************************************************** //The Main Starts Here //********************************************************************************** void menu(){
//scePowerSetClockFrequency(333, 333, 166); // Cpu Clock Currently Set At 333
pspDebugScreenInit(); setupCallbacks(); powerCallbacks(); initGraphics(); SceCtrlData pad, lastpad;
int On_Start_Menu = 1; extern int Select_Setting; Color Color_1 = RGB(0, 0, 0); Color Color_2 = RGB(0, 0, 0); Color Color_3 = RGB(0, 0, 0); Color Color_4 = RGB(0, 0, 0); Color Color_5 = RGB(0, 0, 0); sceCtrlReadBufferPositive(&lastpad, 1); //********************************************************************************** //Load the images //********************************************************************************** char buffer[200]; setxy( 1, 0); printf("Loading Images..."); Image* Menu_1; sprintf(buffer, "Images/Background/Menu_1.png"); Menu_1 = loadImage(buffer); Image* Menu_2; sprintf(buffer, "Images/Background/Menu_2.png"); Menu_2 = loadImage(buffer); //********************************************************************************** //The first loop with the menu starts here //********************************************************************************** while(1) { sceCtrlReadBufferPositive(&pad, 1); if(pad.Buttons != lastpad.Buttons) { lastpad = pad;
// Cross = Ok if(pad.Buttons & PSP_CTRL_CROSS) { if (On_Start_Menu == 1) { // On_Start_Menu = 0; Select_Setting = 1; // Remote Select_Setting = 2; // Mp3 player Select_Setting = 3; // Options Select_Setting = 4; // Credtis Select_Setting = 5; // Exit } // Setting 1 if (Select_Setting = 1) { Ps2_Remote(); if(pad.Buttons & PSP_CTRL_SELECT) { menu(); } } // Setting 2 else if (Select_Setting = 2) { Mp3player(); if(pad.Buttons & PSP_CTRL_SELECT) { menu(); } } // Setting 3 else if (Select_Setting = 3) { blit(0, 0 , 480, 272, Menu_2, 0, 0);
if(pad.Buttons & PSP_CTRL_SELECT) { menu(); } } // Setting 4 else if (Select_Setting = 4) { blit(0, 0 , 480, 272, Menu_2, 0, 0); if(pad.Buttons & PSP_CTRL_SELECT) { menu(); } } // Setting 5 else if (Select_Setting = 5) { sceKernelExitGame(); return 0; } } }
// Up if(pad.Buttons & PSP_CTRL_UP) { if (On_Start_Menu == 1) { Select_Setting--; if (Select_Setting < 1) Select_Setting = 1; } } // Down if(pad.Buttons & PSP_CTRL_DOWN) { if (On_Start_Menu == 1) { Select_Setting++; if (Select_Setting > 3) Select_Setting = 3; } } //********************************************************************************** // blit images blit(0, 0 , 480, 272, Menu_1, 0, 0); Show_The_Time();
//********************************************************************************** // On_Start_Menu if (On_Start_Menu == 1) { if (Select_Setting == 1) { Color_1 = RGB(191, 191, 191); Color_2 = RGB(0, 0, 0); Color_3 = RGB(0, 0, 0); Color_4 = RGB(0, 0, 0); Color_5 = RGB(0, 0, 0); } else if (Select_Setting == 2) { Color_1 = RGB(0, 0, 0); Color_2 = RGB(191, 191, 191); Color_3 = RGB(0, 0, 0); Color_4 = RGB(0, 0, 0); Color_5 = RGB(0, 0, 0); } else if (Select_Setting == 3) { Color_1 = RGB(0, 0, 0); Color_2 = RGB(0, 0, 0); Color_3 = RGB(191, 191, 191); Color_4 = RGB(0, 0, 0); Color_5 = RGB(0, 0, 0); } else if (Select_Setting == 4) { Color_1 = RGB(0, 0, 0); Color_2 = RGB(0, 0, 0); Color_3 = RGB(0, 0, 0); Color_4 = RGB(191, 191, 191); Color_5 = RGB(0, 0, 0); } else if (Select_Setting == 5) { Color_1 = RGB(0, 0, 0); Color_2 = RGB(0, 0, 0); Color_3 = RGB(0, 0, 0); Color_4 = RGB(0, 0, 0); Color_5 = RGB(191, 191, 191); }
printTextScreen(170, 130, "PS2 DVD Remote", Color_1); printTextScreen(170, 140, "Mp3 Player", Color_2); printTextScreen(170, 150, "Options", Color_3); printTextScreen(170, 160, "Credits", Color_4); printTextScreen(170, 170, "Exit", Color_5); }
flipScreen(); }
sceKernelSleepThread(); return 0; }
|
|
|
|
|
Logged
|
|
|
|
Insert_Witty_Name
Global Moderator
Hero Member
Karma: +149/-17
Offline
Posts: 1602
1141.66 points View InventorySend Money to Insert_Witty_Name
|
 |
« Reply #32 on: June 04, 2006, 12:58:38 PM » |
|
You had a } in the wrong place. So the lastpad check was terminated before the up/down check. Simple really All I've done is move one of the } from after the setting 5 part to after the down check (Only menu function shown). void menu(){
//scePowerSetClockFrequency(333, 333, 166); // Cpu Clock Currently Set At 333
pspDebugScreenInit(); setupCallbacks(); powerCallbacks(); initGraphics(); SceCtrlData pad, lastpad;
int On_Start_Menu = 1; extern int Select_Setting; Color Color_1 = RGB(0, 0, 0); Color Color_2 = RGB(0, 0, 0); Color Color_3 = RGB(0, 0, 0); Color Color_4 = RGB(0, 0, 0); Color Color_5 = RGB(0, 0, 0); sceCtrlReadBufferPositive(&lastpad, 1); //********************************************************************************** //Load the images //********************************************************************************** char buffer[200]; setxy( 1, 0); printf("Loading Images..."); Image* Menu_1; sprintf(buffer, "Images/Background/Menu_1.png"); Menu_1 = loadImage(buffer); Image* Menu_2; sprintf(buffer, "Images/Background/Menu_2.png"); Menu_2 = loadImage(buffer); //********************************************************************************** //The first loop with the menu starts here //********************************************************************************** while(1) { sceCtrlReadBufferPositive(&pad, 1); if(pad.Buttons != lastpad.Buttons) { lastpad = pad;
// Cross = Ok if(pad.Buttons & PSP_CTRL_CROSS) { if (On_Start_Menu == 1) { // On_Start_Menu = 0; Select_Setting = 1; // Remote Select_Setting = 2; // Mp3 player Select_Setting = 3; // Options Select_Setting = 4; // Credtis Select_Setting = 5; // Exit } // Setting 1 if (Select_Setting = 1) { Ps2_Remote(); if(pad.Buttons & PSP_CTRL_SELECT) { menu(); } } // Setting 2 else if (Select_Setting = 2) { Mp3player(); if(pad.Buttons & PSP_CTRL_SELECT) { menu(); } } // Setting 3 else if (Select_Setting = 3) { blit(0, 0 , 480, 272, Menu_2, 0, 0);
if(pad.Buttons & PSP_CTRL_SELECT) { menu(); } } // Setting 4 else if (Select_Setting = 4) { blit(0, 0 , 480, 272, Menu_2, 0, 0); if(pad.Buttons & PSP_CTRL_SELECT) { menu(); } } // Setting 5 else if (Select_Setting = 5) { sceKernelExitGame(); return 0; } }
// Up if(pad.Buttons & PSP_CTRL_UP) { if (On_Start_Menu == 1) { Select_Setting--; if (Select_Setting < 1) Select_Setting = 1; } } // Down if(pad.Buttons & PSP_CTRL_DOWN) { if (On_Start_Menu == 1) { Select_Setting++; if (Select_Setting > 3) Select_Setting = 3; } } }
//********************************************************************************** // blit images blit(0, 0 , 480, 272, Menu_1, 0, 0); Show_The_Time();
//********************************************************************************** // On_Start_Menu if (On_Start_Menu == 1) { if (Select_Setting == 1) { Color_1 = RGB(191, 191, 191); Color_2 = RGB(0, 0, 0); Color_3 = RGB(0, 0, 0); Color_4 = RGB(0, 0, 0); Color_5 = RGB(0, 0, 0); } else if (Select_Setting == 2) { Color_1 = RGB(0, 0, 0); Color_2 = RGB(191, 191, 191); Color_3 = RGB(0, 0, 0); Color_4 = RGB(0, 0, 0); Color_5 = RGB(0, 0, 0); } else if (Select_Setting == 3) { Color_1 = RGB(0, 0, 0); Color_2 = RGB(0, 0, 0); Color_3 = RGB(191, 191, 191); Color_4 = RGB(0, 0, 0); Color_5 = RGB(0, 0, 0); } else if (Select_Setting == 4) { Color_1 = RGB(0, 0, 0); Color_2 = RGB(0, 0, 0); Color_3 = RGB(0, 0, 0); Color_4 = RGB(191, 191, 191); Color_5 = RGB(0, 0, 0); } else if (Select_Setting == 5) { Color_1 = RGB(0, 0, 0); Color_2 = RGB(0, 0, 0); Color_3 = RGB(0, 0, 0); Color_4 = RGB(0, 0, 0); Color_5 = RGB(191, 191, 191); }
printTextScreen(170, 130, "PS2 DVD Remote", Color_1); printTextScreen(170, 140, "Mp3 Player", Color_2); printTextScreen(170, 150, "Options", Color_3); printTextScreen(170, 160, "Credits", Color_4); printTextScreen(170, 170, "Exit", Color_5); }
flipScreen(); }
sceKernelSleepThread(); return 0; }
|
|
|
|
|
Logged
|
Coder formerly known as:  Check out my homebrew & C tutorials at http://insomniac.0x89.orgLast updated 6th Oct 06 - Tutorial 2 added.
|
|
|
faati
Full Member
 
Karma: +0/-1
Offline
Posts: 152
0.00 points View InventorySend Money to faati
|
 |
« Reply #33 on: June 04, 2006, 01:49:41 PM » |
|
Inso does everything els look ok ? in the selecting thing ? couz when i select one thing it just starts ir program 
|
|
|
|
|
Logged
|
|
|
|
|
|
|
|
Insert_Witty_Name
Global Moderator
Hero Member
Karma: +149/-17
Offline
Posts: 1602
1141.66 points View InventorySend Money to Insert_Witty_Name
|
 |
« Reply #36 on: June 04, 2006, 03:09:47 PM » |
|
It's probably something to do with this block under your X press check: Select_Setting = 1; // Remote Select_Setting = 2; // Mp3 player Select_Setting = 3; // Options Select_Setting = 4; // Credtis Select_Setting = 5; // Exit
I have no idea why you're setting that variable to different things 5 times... Also, for some reason, you have it set up so that you have to press X and Select it will run the menu function: if(pad.Buttons & PSP_CTRL_SELECT) { menu();
I would seriously look at some generic C tutorials on if statements before you try and do something of this complexity.
|
|
|
|
|
Logged
|
Coder formerly known as:  Check out my homebrew & C tutorials at http://insomniac.0x89.orgLast updated 6th Oct 06 - Tutorial 2 added.
|
|
|
faati
Full Member
 
Karma: +0/-1
Offline
Posts: 152
0.00 points View InventorySend Money to faati
|
 |
« Reply #37 on: June 04, 2006, 03:20:52 PM » |
|
Inso i did this after your toturial, your toturial had 3 , i added two more but my problem is, can i make those to do different things, like when i press x in Select_Setting = 5; // Exit it would Exit the program to eloader. but with mp3 player it would launch mp3player. Understand me ?
|
|
|
|
|
Logged
|
|
|
|
Insert_Witty_Name
Global Moderator
Hero Member
Karma: +149/-17
Offline
Posts: 1602
1141.66 points View InventorySend Money to Insert_Witty_Name
|
 |
« Reply #38 on: June 04, 2006, 03:52:10 PM » |
|
My tutorial has nothing that looks even remotely similar to: Select_Setting = 1; // Remote Select_Setting = 2; // Mp3 player Select_Setting = 3; // Options Select_Setting = 4; // Credtis Select_Setting = 5; // Exit
All you are doing here is: Setting 'Select_Setting' to 1 Setting 'Select_Setting' to 2 Setting 'Select_Setting' to 3 Setting 'Select_Setting' to 4 Setting 'Select_Setting' to 5 Take a look at this with some editing, you'll probably still need to tidy it up to work how you want it to. This is all simple stuff, you should know more than this from the tutorials in the tutorial section of the site. I've put some comments in too to help you along. void menu(){
//scePowerSetClockFrequency(333, 333, 166); // Cpu Clock Currently Set At 333
pspDebugScreenInit(); setupCallbacks(); powerCallbacks(); initGraphics(); SceCtrlData pad, lastpad;
int On_Start_Menu = 1; extern int Select_Setting; Color Color_1 = RGB(0, 0, 0); Color Color_2 = RGB(0, 0, 0); Color Color_3 = RGB(0, 0, 0); Color Color_4 = RGB(0, 0, 0); Color Color_5 = RGB(0, 0, 0); sceCtrlReadBufferPositive(&lastpad, 1); //********************************************************************************** //Load the images //********************************************************************************** char buffer[200]; setxy( 1, 0); printf("Loading Images..."); Image* Menu_1; sprintf(buffer, "Images/Background/Menu_1.png"); Menu_1 = loadImage(buffer); Image* Menu_2; sprintf(buffer, "Images/Background/Menu_2.png"); Menu_2 = loadImage(buffer); //********************************************************************************** //The first loop with the menu starts here //********************************************************************************** while(1) { sceCtrlReadBufferPositive(&pad, 1); if(pad.Buttons != lastpad.Buttons) { lastpad = pad;
// Cross = Ok if(pad.Buttons & PSP_CTRL_CROSS) { //WE CLICKED X if (On_Start_Menu == 1) {
// Setting 1 if (Select_Setting = 1) { //WE HAVE PSP DVD REMOTE SELECTED, LAUNCH THE PS2_REMOTE FUNCTION Ps2_Remote(); }
// Setting 2 else if (Select_Setting = 2) { //WE HAVE THE MP3 PLAYER SELECTED, LAUNCH THE MP3PLAYER FUNCTION Mp3player(); }
// Setting 3 else if (Select_Setting = 3) { //THE FOLLOWING IMAGE WILL ONLY BE BLITTED WHEN X IS PRESSED, IS THIS RIGHT? blit(0, 0 , 480, 272, Menu_2, 0, 0);
}
// Setting 4 else if (Select_Setting = 4) { //THE FOLLOWING IMAGE WILL ONLY BE BLITTED WHEN X IS PRESSED, IS THIS RIGHT? blit(0, 0 , 480, 272, Menu_2, 0, 0); } // Setting 5 else if (Select_Setting = 5) { //EXIT sceKernelExitGame(); return 0; } } }
// Up if(pad.Buttons & PSP_CTRL_UP) { if (On_Start_Menu == 1) { Select_Setting--; if (Select_Setting < 1) Select_Setting = 1; } } // Down if(pad.Buttons & PSP_CTRL_DOWN) { if (On_Start_Menu == 1) { Select_Setting++; //EDITED THE NEXT LINE TO BE 5 INSTEAD OF 3 if (Select_Setting > 5) Select_Setting = 5; } } }
//********************************************************************************** // blit images blit(0, 0 , 480, 272, Menu_1, 0, 0); Show_The_Time();
//********************************************************************************** // On_Start_Menu if (On_Start_Menu == 1) { if (Select_Setting == 1) { Color_1 = RGB(191, 191, 191); Color_2 = RGB(0, 0, 0); Color_3 = RGB(0, 0, 0); Color_4 = RGB(0, 0, 0); Color_5 = RGB(0, 0, 0); } else if (Select_Setting == 2) { Color_1 = RGB(0, 0, 0); Color_2 = RGB(191, 191, 191); Color_3 = RGB(0, 0, 0); Color_4 = RGB(0, 0, 0); Color_5 = RGB(0, 0, 0); } else if (Select_Setting == 3) { Color_1 = RGB(0, 0, 0); Color_2 = RGB(0, 0, 0); Color_3 = RGB(191, 191, 191); Color_4 = RGB(0, 0, 0); Color_5 = RGB(0, 0, 0); } else if (Select_Setting == 4) { Color_1 = RGB(0, 0, 0); Color_2 = RGB(0, 0, 0); Color_3 = RGB(0, 0, 0); Color_4 = RGB(191, 191, 191); Color_5 = RGB(0, 0, 0); } else if (Select_Setting == 5) { Color_1 = RGB(0, 0, 0); Color_2 = RGB(0, 0, 0); Color_3 = RGB(0, 0, 0); Color_4 = RGB(0, 0, 0); Color_5 = RGB(191, 191, 191); }
printTextScreen(170, 130, "PS2 DVD Remote", Color_1); printTextScreen(170, 140, "Mp3 Player", Color_2); printTextScreen(170, 150, "Options", Color_3); printTextScreen(170, 160, "Credits", Color_4); printTextScreen(170, 170, "Exit", Color_5); }
flipScreen(); }
sceKernelSleepThread(); return 0; }
Basically all you're doing is catching what is selected when you click X and acting based on those results. Think about it logically, heck even draw a flow diagram on a bit of paper if it helps, it all makes sense.
|
|
|
|
|
Logged
|
Coder formerly known as:  Check out my homebrew & C tutorials at http://insomniac.0x89.orgLast updated 6th Oct 06 - Tutorial 2 added.
|
|
|
faati
Full Member
 
Karma: +0/-1
Offline
Posts: 152
0.00 points View InventorySend Money to faati
|
 |
« Reply #39 on: June 04, 2006, 03:55:05 PM » |
|
sry if i made you angry mate, but its all i know im new to c  after all these forums are made for noobs 
|
|
|
|
|
Logged
|
|
|
|
|
|
|
|
faati
Full Member
 
Karma: +0/-1
Offline
Posts: 152
0.00 points View InventorySend Money to faati
|
 |
« Reply #42 on: June 04, 2006, 04:04:50 PM » |
|
Inso the thing does the same as mine did it dosent matter which setting i chose it does the same (Remote).
|
|
|
|
|
Logged
|
|
|
|
Insert_Witty_Name
Global Moderator
Hero Member
Karma: +149/-17
Offline
Posts: 1602
1141.66 points View InventorySend Money to Insert_Witty_Name
|
 |
« Reply #43 on: June 04, 2006, 04:10:18 PM » |
|
sry if i made you angry mate, but its all i know im new to c  after all these forums are made for noobs  Not angry mate, just think that if you don't know simple things like this then you are running before you can walk, so to speak. There are some good generic beginner C tutorials out there that would benefit you infinitely. Personally I've only been programming in C since 12th May, so it's not that hard to pick up.
|
|
|
|
|
Logged
|
Coder formerly known as:  Check out my homebrew & C tutorials at http://insomniac.0x89.orgLast updated 6th Oct 06 - Tutorial 2 added.
|
|
|
Insert_Witty_Name
Global Moderator
Hero Member
Karma: +149/-17
Offline
Posts: 1602
1141.66 points View InventorySend Money to Insert_Witty_Name
|
 |
« Reply #44 on: June 04, 2006, 04:13:34 PM » |
|
Heh, I missed something. You are checking the selected setting like this: if (Select_Setting = 1) {
It needs an extra = if (Select_Setting == 1) {
That goes for all your if blocks on the X check part.
|
|
|
|
|
Logged
|
Coder formerly known as:  Check out my homebrew & C tutorials at http://insomniac.0x89.orgLast updated 6th Oct 06 - Tutorial 2 added.
|
|
|
|