C/C++ Programming Help Thread
This is a discussion on C/C++ Programming Help Thread within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; Does some1 knows the code ore a sample to printf the mobo of the psp, the firmware and the available ...
-
12-29-2009, 08:00 AM #9991QJ Gamer Green
- Registriert seit
- Jun 2009
- Beiträge
- 61
- Points
- 2.003
- Level
- 27
- Downloads
- 0
- Uploads
- 0
PSP Mobo and firmware reader and RAM
Does some1 knows the code ore a sample to printf the mobo of the psp, the firmware and the available RAM(i got a slim if it's necessary)???And which files should I include?
BTW Sorry for double post
Geändert von LegendMythe (12-29-2009 um 12:08 PM Uhr)
-
12-29-2009, 08:06 AM #9992QJ Gamer Green
- Registriert seit
- Jun 2009
- Beiträge
- 61
- Points
- 2.003
- Level
- 27
- Downloads
- 0
- Uploads
- 0
-
12-29-2009, 11:54 AM #9993QJ Gamer Gold

- Registriert seit
- Nov 2008
- Ort
- CAD
- Beiträge
- 693
- Points
- 13.372
- Level
- 75
- Downloads
- 19
- Uploads
- 4
to get the CFW version and the available RAM, you could do this:
Code:#include <pspsysmem.h> #include <stdio.h> #include <stdlib.h> char getFWversion() { int ver = sceKernelDevkitVersion(); char *aStr; char buffer[16]; sprintf(buffer, "%x", ver); buffer[1]='.'; buffer[3] = buffer[4]; buffer[4] = 0; aStr = buffer; return aStr; } int getFreeRAM() { void *buf[64]; int i; for(i = 0; i < 64; i++) { buf[i] = malloc(1024*1024); if(!buf[i]) break; } int result = i; for(; i >= 0; i--) { free(buf[i]); } return (result*1024*1024); } //later on: int main(void) { //somewhere in your code: pspDebugScreenInit(); pspDebugScreenSetXY(0,0); pspDebugScreenPrintf("Your CFW version is: %s.\n", getFWversion()); pspDebugScreenPrintf("There's %i of available RAM.", getFreeRAM()); }yes
Zitat von LegendMythe
I want to clear the unused part of the RAM, the "junk", "grabage", etc.
Zitat von LegendMythe
Geändert von mootjeuh (12-29-2009 um 12:12 PM Uhr)
-
12-29-2009, 12:06 PM #9994QJ Gamer Green
- Registriert seit
- Jun 2009
- Beiträge
- 61
- Points
- 2.003
- Level
- 27
- Downloads
- 0
- Uploads
- 0
Ty but don't i need a lib in my makefile?Cause if i compile I get some errors:
main.c: In function 'getFWversion':
main.c:25: warning: return makes integer from pointer without a cast
main.c: In function 'main':
main.c:78: warning: format '%s' expects type 'char *', but argument 2 has type '
int'
main.c: In function 'getFWversion':
main.c:26: internal compiler error: Segmentation fault
If some1 knows a way to read the mobo of the psp please pm me ore something...
-
12-29-2009, 12:22 PM #9995QJ Gamer Gold

- Registriert seit
- Nov 2008
- Ort
- CAD
- Beiträge
- 693
- Points
- 13.372
- Level
- 75
- Downloads
- 19
- Uploads
- 4
-
12-29-2009, 12:42 PM #9996QJ Gamer Green
- Registriert seit
- Jun 2009
- Beiträge
- 61
- Points
- 2.003
- Level
- 27
- Downloads
- 0
- Uploads
- 0
I already use pspmini :)
I found something i changed the char getFWversion()
{...} to char* getFWversion()
{...} and now I can compile it but the program say my firmware is 9fbfdd8 and i have 5.50GEN-3.
I tried changing printf("Your CFW version is: %s.\n\n\n", getFWversion()); to printf("Your CFW version is: %x.\n\n\n", getFWversion()); like the char* getFWversion and now it says that my firmware is "9fbfdd8"...Geändert von LegendMythe (12-29-2009 um 01:23 PM Uhr)
-
12-29-2009, 12:56 PM #9997
-- Code Monkey : Sarien, Fishguts, Cracks and Crevices --
"Did IQ's just drop sharply while I was away?" (Ripley)
-
12-29-2009, 01:02 PM #9998QJ Gamer Green
- Registriert seit
- Jun 2009
- Beiträge
- 61
- Points
- 2.003
- Level
- 27
- Downloads
- 0
- Uploads
- 0
-
12-29-2009, 04:15 PM #9999QJ Gamer Gold

- Registriert seit
- Nov 2008
- Ort
- CAD
- Beiträge
- 693
- Points
- 13.372
- Level
- 75
- Downloads
- 19
- Uploads
- 4
-
12-29-2009, 06:04 PM #10000
-- Code Monkey : Sarien, Fishguts, Cracks and Crevices --
"Did IQ's just drop sharply while I was away?" (Ripley)
-
12-30-2009, 02:39 AM #10001QJ Gamer Green
- Registriert seit
- Jun 2009
- Beiträge
- 61
- Points
- 2.003
- Level
- 27
- Downloads
- 0
- Uploads
- 0
Dude...Why the f*ck do you think this thread is called a freaking HELP thread.If you don't want to help people and you hate asking for help then go to the discusion(which isn't this thread!!!) thread!:Argh:
BTW i can figure stuff out on my on, but this i couldn't thats why I came to the freaking HELP thread!
Anayways ty for evryone that helpt...
-
12-30-2009, 08:02 AM #10002Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
Never seen this error before , it happens while using the 4.XX m33 SDK , anyone know the solution?Code:ioFunctions/search.o: In function `searchForFile': search.c:(.text+0x2b8): undefined reference to `free' search.c:(.text+0x47c): undefined reference to `malloc' ioFunctions/fileBrowser.o: In function `recacheGameDir': fileBrowser.c:(.text+0xa0): undefined reference to `free' fileBrowser.c:(.text+0xdc): undefined reference to `memalign' ioFunctions/fileBrowser.o: In function `fileBrowser': fileBrowser.c:(.text+0x278): undefined reference to `free' fileBrowser.c:(.text+0x560): undefined reference to `malloc'
-
12-30-2009, 08:12 AM #10003QJ Gamer Green
- Registriert seit
- Jun 2009
- Beiträge
- 61
- Points
- 2.003
- Level
- 27
- Downloads
- 0
- Uploads
- 0
-
12-30-2009, 08:25 AM #10004Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
-
12-30-2009, 08:47 AM #10005QJ Gamer Gold

- Registriert seit
- Nov 2008
- Ort
- CAD
- Beiträge
- 693
- Points
- 13.372
- Level
- 75
- Downloads
- 19
- Uploads
- 4
seems that you didn't include <stdlib.h> and <stdio.h>, try putting this at the first line of your .c :
but I highly doubt it's coming from your .c, I'm guessing you don't have them in your Makefile but that impossible coz they're standard C files, could you post your Makefile?Code:#include <stdlib.h> #include <stdio.h>
yeah, that's the weird part, it DOESN'T need a lib
OR, either your compiler or/and pspsdk is/are screwed up
-
12-30-2009, 09:34 AM #10006QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
good memory managment and you don't need to clear the RAM, if ur refering to the data not allocated yet(i.e. u wanna cover your tracks or something) then simply calculate the remaining ram, and create an array that size, then randomize and/or set it to 0, however anything in use should NEVER be cleared that isn't your's(plus their's protection against doing it), nothing is junk when it's in use by another program
1. Failed....again...
2. http://slicer.gibbocool.com/ stay updated on all my projects
3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been
-
12-30-2009, 09:41 AM #10007QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
that should work, however more of a description would help, however this can lead to problems(division by 0, or floating point->int(assuming these are int's) errors, and of course the while loop ensures negative doesn't happen, this doesn't, some some checks can take away your problems)Code:xxx+=(displon-lonwork)/zoom lonwork += (displon-lonwork)*zoom; yyy+=(latwork-displat)/zoom latwork -= (latwork-displat)*zoom;
edit: opps, double post my bad
edit:
Legend, if your output is in bytes, and you want it to be in mb's, than you must convert from bytes->kbytes->mb's, that is what DF is attempting to say(although he should not have acted out in anger against you), however also listen to the people here, and don't act out against them as wellGeändert von slicer4ever (12-30-2009 um 01:22 PM Uhr)
1. Failed....again...
2. http://slicer.gibbocool.com/ stay updated on all my projects
3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been
-
12-30-2009, 10:07 AM #10008Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
No I dindt forget to include them, so here is my Makefile:
Code:TARGET = test OBJS = main.o \ menu.o \ audio/audio.o \ ioFunctions/search.o \ ioFunctions/fileBrowser.o \ exports.o INCDIR = ../../include CFLAGS = -O2 -Os -G0 -Wall -fshort-wchar -fno-pic -mno-check-zero-division CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti ASFLAGS = $(CFLAGS) BUILD_PRX = 1 PRX_EXPORTS = exports.exp USE_KERNEL_LIBC = 1 USE_KERNEL_LIBS = 1 PSP_FW_VERSION = 371 LIBDIR = ../../lib LIBS = -lpsprtc \ -lpspwlan \ -lstdc++ \ -lpsputility \ -lpsppower \ -lpspgu \ -lpng \ -lz \ -lm \ -lmad \ -lpspaudiolib \ -lpspaudio \ -lpspusb \ -lpspusbstor \ -lpspmp3 PSPSDK=$(shell psp-config --pspsdk-path) include $(PSPSDK)/lib/build_prx.mak
-
12-30-2009, 10:11 AM #10009QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
1. Failed....again...
2. http://slicer.gibbocool.com/ stay updated on all my projects
3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been
-
12-30-2009, 10:15 AM #10010Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
mayby the second error can help you:
this error gives me the feeling that my sdk is screwed upCode:/usr/local/pspdev/psp/sdk/lib/libpspdebug.a(pspDebugScreenInit.o): In function ` pspDebugScreenInitEx': /home/Roel/psptoolchain/build/pspsdk/src/debug/scr_printf.c:141: undefined refer ence to `sceGeEdramGetAddr' /usr/local/pspdev/psp/sdk/lib/libpspdebug.a(pspDebugScreenPrintf.o): In function `pspDebugScreenPrintf': /home/Roel/psptoolchain/build/pspsdk/src/debug/scr_printf.c:432: undefined refer ence to `vsnprintf' collect2: ld returned 1 exit status
-
12-30-2009, 10:17 AM #10011Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
-
12-30-2009, 10:33 AM #10012QJ Gamer Gold

- Registriert seit
- Nov 2008
- Ort
- CAD
- Beiträge
- 693
- Points
- 13.372
- Level
- 75
- Downloads
- 19
- Uploads
- 4
yeah, your SDK is definitely screwed up ;) if you're on Windows, install minPSPw
-
12-30-2009, 11:50 AM #10013
I did help you, I pointed you in the right direction, I just didn't give you a cut and paste answer that you wanted. I asked you a simple question on the ratio of bytes to kb to mb (basically telling you you need to divide one to the other) and you got all "WTF!" in my face for giving you the answer.
Yeah, this is a help thread, remember that when you want to get all hostile and "WTF" in peoples faces.-- Code Monkey : Sarien, Fishguts, Cracks and Crevices --
"Did IQ's just drop sharply while I was away?" (Ripley)
-
12-31-2009, 04:38 AM #10014
Achievements:
- Registriert seit
- Dec 2009
- Ort
- SomeWhere
- Beiträge
- 9
- Points
- 1.361
- Level
- 20
- My Mood
-
- Downloads
- 0
- Uploads
- 0
This is maybe something noby but I can't make it work...
I followed one of the tuts for making a menu with graphics.h.Now I want to add to the menu that when i press a button like cross that it makes the screen clear and print something on it.But now i tried that but i now have to hold X...
My code:
Code:int main() { SetupCallbacks(); initGraphics(); pspDebugScreenInit(); SceCtrlData pad; while(1) { sceCtrlReadBufferPositive(&pad,1); fillScreenRect(white,0,0,480,272); timer++; for(foo=0;foo<10;foo++) { if((pad.Buttons & PSP_CTRL_CROSS) && (select == 0)) { printTextScreen(200,foo*10+70,menuItems[foo],black); } printTextScreen(200,select*10+70,menuItems[select],red); if((pad.Buttons & PSP_CTRL_UP) && (timer > 10) && (select > 0)) { select--; timer = 0; } else if ((pad.Buttons & PSP_CTRL_DOWN) && (timer > 10) && (select < 9)) { select++; timer = 0; } if((pad.Buttons & PSP_CTRL_CROSS) && (select == 0)) { pspDebugScreenClear();//if add pspdebug.h and stuff printf("blablabla");//I defined printf to flipScreen(); sceDisplayWaitVblankStart(); } return 0; }
-
12-31-2009, 06:06 AM #10015QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
it's called states, diffrent states of the game, reflect diffrent things to happen:
hope this helpsCode:int main() { SetupCallbacks(); initGraphics(); pspDebugScreenInit(); SceCtrlData pad; int State=0; while(1){ sceCtrlReadBufferPositive(&pad,1); fillScreenRect(white,0,0,480,272); if(State==0){ timer++; for(foo=0;foo<10;foo++) { if((pad.Buttons & PSP_CTRL_CROSS) && (select == 0)) { printTextScreen(200,foo*10+70,menuItems[foo],black); } printTextScreen(200,select*10+70,menuItems[select],red); if((pad.Buttons & PSP_CTRL_UP) && (timer > 10) && (select > 0)) { select--; timer = 0; } else if ((pad.Buttons & PSP_CTRL_DOWN) && (timer > 10) && (select < 9)) { select++; timer = 0; } if((pad.Buttons & PSP_CTRL_CROSS) && (select == 0)) { State=1; } } }else if(State==1){ printf("blablabla");//I defined printf to flipScreen(); if(pad.Buttons&PSP_CTRL_CIRCLE){ State=0; } } } return 0; }1. Failed....again...
2. http://slicer.gibbocool.com/ stay updated on all my projects
3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been
-
12-31-2009, 06:06 AM #10016QJ Gamer Silver

- Registriert seit
- Jan 2006
- Ort
- Germany
- Beiträge
- 926
- Points
- 14.087
- Level
- 77
- Downloads
- 0
- Uploads
- 0
Raphs board rules #31: Excessive use of punctuation is either a sign of a lesser ego or a small mind. Avoid it if you don't want to look like a total moron.
Raphs board rules #17: When you need to ask whether you are capable of doing something, you are not.
Raphs board rules #2: Exploits aren't found by changing version numbers, blindly merging data into a file or turning your PSP upside down.
Raphs board rules #1: If you have no clue how exploits work, don't come up with ideas about them.
-
12-31-2009, 06:07 AM #10017QJ Gamer Silver

- Registriert seit
- Jan 2006
- Ort
- Germany
- Beiträge
- 926
- Points
- 14.087
- Level
- 77
- Downloads
- 0
- Uploads
- 0
Raphs board rules #31: Excessive use of punctuation is either a sign of a lesser ego or a small mind. Avoid it if you don't want to look like a total moron.
Raphs board rules #17: When you need to ask whether you are capable of doing something, you are not.
Raphs board rules #2: Exploits aren't found by changing version numbers, blindly merging data into a file or turning your PSP upside down.
Raphs board rules #1: If you have no clue how exploits work, don't come up with ideas about them.
-
12-31-2009, 06:19 AM #10018
Achievements:
- Registriert seit
- Dec 2009
- Ort
- SomeWhere
- Beiträge
- 9
- Points
- 1.361
- Level
- 20
- My Mood
-
- Downloads
- 0
- Uploads
- 0
-
12-31-2009, 06:26 AM #10019QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
well, look at the code, it's designed to do that, when state = 0, then show the menu, when state = 1 it'll print the words out(which is what i thought u originally wanted to happen)
now then, if u want both menu and text, but without holding the button think about what you'd have to do:
1. detect when x is pressed(u've already done that)
2. set a variable saying x has been pressed
3. check if that variable is set, if so print the string aswell as the menu
it's not hard, bit of logic and variable handling=-), it's similar to how states work, but inside the menu code itself=-)1. Failed....again...
2. http://slicer.gibbocool.com/ stay updated on all my projects
3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been
-
12-31-2009, 06:52 AM #10020
Achievements:
- Registriert seit
- Dec 2009
- Ort
- SomeWhere
- Beiträge
- 9
- Points
- 1.361
- Level
- 20
- My Mood
-
- Downloads
- 0
- Uploads
- 0
Yea i know and it works thanks but now when i have pressed X it works but the background keep flashing from white to black.And only the first menu item is showd, but when i go down the next buttons show but the first option is still in the select color...It's kinda weird got some suggestions?
code:Code:int main() { SetupCallbacks(); initGraphics(); pspDebugScreenInit(); SceCtrlData pad; int State=0; State=0; while(1){ sceCtrlReadBufferPositive(&pad,1); if(State==0){ timer++; for(foo=0;foo<10;foo++) { if((pad.Buttons & PSP_CTRL_CROSS) && (select == 0)) { printTextScreen(200,foo*10+70,menuItems[foo],black); } printTextScreen(200,select*10+70,menuItems[select],red); if((pad.Buttons & PSP_CTRL_UP) && (timer > 10) && (select > 0)) { select--; timer = 0; } else if ((pad.Buttons & PSP_CTRL_DOWN) && (timer > 10) && (select < 9)) { select++; timer = 0; } if((pad.Buttons & PSP_CTRL_CROSS) && (select == 0)) { State=1; } flipScreen(); } }else if(State==1){ pspDebugScreenClear(); printTextScreen(5,5, "blabla", red); flipScreen(); sceDisplayWaitVblank(); if(pad.Buttons&PSP_CTRL_CIRCLE){ pspDebugScreenClear(); State=0; } } if((pad.Buttons & PSP_CTRL_CROSS) && (select == 0)) { State==1; } } return 0; }Geändert von ButMan (12-31-2009 um 07:09 AM Uhr)


LinkBack URL
About LinkBacks
Mit Zitat antworten


Hello everyone I am new here and I am glad to be part of this amazing community and I think there...
New to forum