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; is it possible at all to stop the psp from shutting down after some1 holds the power button up, i'd ...
-
03-07-2008, 06:08 PM #8101QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
is it possible at all to stop the psp from shutting down after some1 holds the power button up, i'd imagine it's hardware wired in, but i still wanna check to see if it's remotly possible
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
-
03-07-2008, 06:30 PM #8102
No. Its the hardware.
Zitat von slicer4ever
-
03-07-2008, 06:49 PM #8103QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
i figured as much, thanks for confirming it
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
-
03-08-2008, 12:21 PM #8104I'm back!

- Registriert seit
- Feb 2007
- Ort
- England
- Beiträge
- 902
- Points
- 8.236
- Level
- 61
- Downloads
- 0
- Uploads
- 0
You CAN disable this, its not hardware at all. The function you require is in psppower.h and is:
Zitat von slicer4ever
-Aura/**
* Lock power switch
*
* Note: if the power switch is toggled while locked
* it will fire immediately after being unlocked.
*
* @param unknown - pass 0
*/
int scePowerLock(int unknown);
-
03-08-2008, 05:59 PM #8105QJ Gamer Bronze

- Registriert seit
- Aug 2007
- Ort
- Australia
- Beiträge
- 659
- Points
- 8.045
- Level
- 60
- Downloads
- 0
- Uploads
- 0
Hey guys, im looking at doing some effects (transition like) for a game. I want to try and have a fade effect so first i need a function to return the colour of every pixel on the screen into an array. Would something like this work?
Code:int count; int pixely; int pixelx u32 pixelcol[130560];//130560 is amount of pixels on screen while(pixelx <= 480) { pixely ++; count ++; if(pixely > 272) { pixelx ++; pixely = 0; } pixelcol[count] = getPixelScreen(pixelx, pixely); }
-
03-08-2008, 06:25 PM #8106Developer

- Registriert seit
- Mar 2006
- Beiträge
- 1.026
- Points
- 7.577
- Level
- 58
- Downloads
- 0
- Uploads
- 0
You're thinking about it the wrong way.
Draw a quad over the screen last thing in your drawing loop.
Set the alpha of the quad based on if you're fading out or fading in.
Fading out, then you want to increment the alpha value from 0-255. Fading in you want to decrement it from 255-0.
Check out my homebrew & C tutorials at http://insomniac.0x89.org/
Coder formerly known as Insomniac197
tshirtz: what is irshell ??
Atarian_: it's where people who work for the IRS go when they die
-
03-08-2008, 06:27 PM #8107QJ Gamer Bronze

- Registriert seit
- Aug 2007
- Ort
- Australia
- Beiträge
- 659
- Points
- 8.045
- Level
- 60
- Downloads
- 0
- Uploads
- 0
oh, nice. Man thats a good idea(its not that amazing but just a nice way of doing it) i never thought of doing it like that. Thanks man

-= Double Post =-
just for future reference, if for some reason i need it, would my code still work?Geändert von Xsjado7 (03-08-2008 um 06:29 PM Uhr) Grund: Automerged Doublepost
-
03-08-2008, 07:46 PM #8108words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
Yes, as IWN said use a quad with a varying opacity. On the PSP (probably on soem PCs as well) avoid huge loops like that. I've done motion blur in LUA and the frame rate is awful.
Even after narrowing down the blurring zone to be 480x10 i still was getting like 3 fps...
...at what speed must I live.. to be able to see you again?...
Projects
You can support my Open World 3D RPG for PSP by voting for it here
-
03-08-2008, 07:52 PM #8109QJ Gamer Bronze

- Registriert seit
- Aug 2007
- Ort
- Australia
- Beiträge
- 659
- Points
- 8.045
- Level
- 60
- Downloads
- 0
- Uploads
- 0
dang, thats some seriously choppy stuff. Thanks for the help guys. The transitions/effects add that extra bit of professional-ism to a game/app
-
03-08-2008, 11:56 PM #8110It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
All that does is disable sleep mode, actually.
Zitat von Auraomega
pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ
-
03-09-2008, 12:07 AM #8111words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
Xsjado - Heh...
You'd be surprised at the very simple arithmetic used to make some of the most amusing transitions ;) I'm using a neat transition system in my current project. Transitions are fun to make, then actually being able to make use of them really sets your game apart from others.
Here's one that makes the scene underneath (the next state hint hint) kinda "pop" out of no where (well, depends on the transition speed)
Not the best, nothing crazy, etc. but hey it's one ;)Code:// Declare these where ever they can be accesible bool bEntering; // Flag to tell if were entering a game state Vector2D vTransition; // 2D Vector class or structure used for transitioning game states const int TRANSITION_X_SPEED = 10; // The transitions speed x-coordinate wise const int TRANSITION_Y_SPEED = 6; // " y-coordinate wise // Initialize (call this when initializing the next state) bEntering = true; vTransition.x = 0.0f; vTransition.y = 0.0f; // Think (call this during the thinking part of the game states, out of any switch statement or w/e) if (bEntering) { if (vTransition.x >= SCREEN_WIDTH / 2) { bEntering = false; } else { vTransition.x += TRANSITION_X_SPEED; vTransition.y += TRANSITION_Y_SPEED; } } // Draw (call this in the drawing part of the game states, out of any switch statements or w/e) if (bEntering) // Replace oslDrawFillRect(x,y,x2,y2,color) with whatever your graphics library supports { // Draw our neat transition GFX (a square expands - it's 4 points are then used to draw black rectangles everywhere BUT inside of it, the stuff inside it is the next state being drawn below it) oslDrawFillRect(0, 0, int (SCREEN_WIDTH / 2 - vTransition.x), SCREEN_HEIGHT, RGB(0,0,0)) oslDrawFillRect(int (SCREEN_WIDTH / 2 + vTransition.x), 0, SCREEN_WIDTH, SCREEN_HEIGHT, RGB(0,0,0)); oslDrawFillRect(int (SCREEN_WIDTH / 2 - vTransition.x), 0, int (SCREEN_WIDTH / 2 + vTransition.x), int(SCREEN_HEIGHT / 2 - vTransition.y), RGB(0,0,0)); oslDrawFillRect(int (SCREEN_WIDTH / 2 - vTransition.x), int(SCREEN_HEIGHT / 2 + vTransition.y), int (SCREEN_WIDTH / 2 + vTransition.x), SCREEN_HEIGHT, RGB(0,0,0)); }
P.S. it'd be nice to have a huge collection of transitions. Sure some will be more render-engine specific but hey it'd be a good developer resourceGeändert von SG57 (03-09-2008 um 12:20 AM Uhr)

...at what speed must I live.. to be able to see you again?...
Projects
You can support my Open World 3D RPG for PSP by voting for it here
-
03-09-2008, 01:12 AM #8112QJ Gamer Bronze

- Registriert seit
- Aug 2007
- Ort
- Australia
- Beiträge
- 659
- Points
- 8.045
- Level
- 60
- Downloads
- 0
- Uploads
- 0
I was thinking about that earlier. Just gather a load together into a library and port it to work with a few different graphics libs like OSL/TriEngine/Graphics.h
Zitat von SG57
-
03-10-2008, 01:43 PM #8113I'm back!

- Registriert seit
- Feb 2007
- Ort
- England
- Beiträge
- 902
- Points
- 8.236
- Level
- 61
- Downloads
- 0
- Uploads
- 0
Is there any way to get EBOOTs to be loadexec'ed from flash0-3? Loading PRX files works fine, but trying to use the loadExec calls I get an error (SCE_KERNEL_ERROR_ILLEGAL _PERM_CALL I believe). I'm not sure if there is any work around from this?
-Aura
-
03-10-2008, 03:07 PM #8114
You can't just use sceKernelLoadExec for EBOOTs. If I recall correctly, you have to first decompress the .ELF from the EBOOT. Check out this thread.
Zitat von Auraomega
http://forums.qj.net/f-psp-developme...eps-64080.html[IMG]http://upload.wikimedia.org/wikipedia/commons/thumb/c/c5/Zoso.svg/744px-Zoso.svg.png[/IMG]
Looking for some good C programming tutorials for the PSP? Look no further! [URL="http://psp-coding.com/"]PSP-Coding.com[/URL] is your source for all your PSP coding needs.
-
03-10-2008, 03:42 PM #8115I'm back!

- Registriert seit
- Feb 2007
- Ort
- England
- Beiträge
- 902
- Points
- 8.236
- Level
- 61
- Downloads
- 0
- Uploads
- 0
OMG, I could kiss you right now :humped: I've been trying to get this working for a while and have been reduced to using the new ms versions of the loadexec (which work with EBOOT.PBP natively without any messing around). All I can say is thank you deeply, and I can't believe it was something that simple
-Aura
EDIT I:
Hmm, no wait, seems to not work flash - flash. Ms0 - flash works fine, but flash - flash just fails, oh well, back to the drawing board...
EDIT II:
It works flash - flash in 1.50, but not in 3.XX, which is where this app is targeted.Geändert von Auraomega (03-10-2008 um 04:08 PM Uhr) Grund: Automerged Doublepost
-
03-10-2008, 05:21 PM #8116
Yes, I remember hearing something about not being able to run EBOOTs from the flash in 3.xx, but I didn't know if it was true or not. Do they still run from the memory stick? Maybe copy it to the memory stick before booting? Is this an EBOOT that you coded? Maybe you could recompile it into a PRX.
Zitat von Auraomega
[IMG]http://upload.wikimedia.org/wikipedia/commons/thumb/c/c5/Zoso.svg/744px-Zoso.svg.png[/IMG]
Looking for some good C programming tutorials for the PSP? Look no further! [URL="http://psp-coding.com/"]PSP-Coding.com[/URL] is your source for all your PSP coding needs.
-
03-10-2008, 07:12 PM #8117QJ Gamer Blue
- Registriert seit
- Oct 2007
- Ort
- Illinois
- Beiträge
- 158
- Points
- 3.734
- Level
- 38
- Downloads
- 0
- Uploads
- 0
I need some help. Im trying to get a program to recognize the motherboard of the PSP, so I did this:
I get errorCode:if ((tachyon = 0x00300000 && baryon = 0x00040600)) { printf("Motherboard = TA-081 1g\n"); }I know it has to do with the (( and the &&, how would I code that part so the program would 'use' both tachyon and baryon?error: invalid lvalue in assignment
-
03-10-2008, 07:36 PM #8118
If statements use two ='s instead of one. Change it to:
if ((tachyon == 0x00300000 && baryon == 0x00040600))
Hope that helps.Atheist, because I just won't believe in what doesn't show itself to me.
-
03-10-2008, 08:30 PM #8119QJ Gamer Blue
- Registriert seit
- Oct 2007
- Ort
- Illinois
- Beiträge
- 158
- Points
- 3.734
- Level
- 38
- Downloads
- 0
- Uploads
- 0
Aha, thanks! I appreciate the help and it works now.
Zitat von Durka Durka Mahn
-
03-11-2008, 09:45 AM #8120I'm back!

- Registriert seit
- Feb 2007
- Ort
- England
- Beiträge
- 902
- Points
- 8.236
- Level
- 61
- Downloads
- 0
- Uploads
- 0
Yeah, I've not actually read it anywhere but I assumed this would likely be the case. It is an app I made, and compiling in prx format is possible, but it physically needs to be loadExec'ed from flash, not just loaded as another module, I'm not actually being rejected as such, its attempting to load it from flash, and not giving any errors, but then it just returns me to the XMB (Project4 in my case), I'll do some more research into it, as I also want to be able to do this with code that is not my own.
Zitat von Judas
The only other thing I can think of is if I write my own driver like that of DevHook and somehow trick the PSP into believing that its loading from ms0:/, but so far I've had no luck in that department either.
If you can think of any other options I'm all ears, the more ideas I have the more likely I am to find a work around to my problem.
-Aura
-
03-11-2008, 11:56 AM #8121
I think you're right, where you could probably re-assign the flash so that the PSP thinks it's the memory stick. Or maybe pack the EBOOT into an ISO structure, and mount the ISO. I haven't used Project4 yet, but doesn't it run ISOs?
Zitat von Auraomega
Or maybe the restriction for sceKernelLoadExec is in a 3.xx PRX, and you can maybe load the 1.5 PRX and use that function instead.
I'm not really an expert in the way the PSP handles files and executables, so I can't offer that much help.[IMG]http://upload.wikimedia.org/wikipedia/commons/thumb/c/c5/Zoso.svg/744px-Zoso.svg.png[/IMG]
Looking for some good C programming tutorials for the PSP? Look no further! [URL="http://psp-coding.com/"]PSP-Coding.com[/URL] is your source for all your PSP coding needs.
-
03-11-2008, 12:01 PM #8122I'm back!

- Registriert seit
- Feb 2007
- Ort
- England
- Beiträge
- 902
- Points
- 8.236
- Level
- 61
- Downloads
- 0
- Uploads
- 0
Well I just tried the re-assigning idea, and I got an error with that, so thats yet another idea gone. Project4 can run the I word yep, I will definatly try that as I hadn't thought of that previously, only question is, how do I actually do so? I'll also have a dabble in a little while at trying to load 1.50 stuff instead of 3.XX, if that works its a start, but it still won't be very Slim friendly (still, a start is a start and it may set me on the right path).
Zitat von Judas
Thanks again.
-Aura
-
03-11-2008, 12:13 PM #8123
http://forums.qj.net/f-psp-homebrew-...mat-46926.html
Zitat von Auraomega
That's how to convert a PSP to an ISO. The ISO will be at least double the size using that method. Unless you have Project4 set to run either BOOT.BIN or EBOOT.BIN. Because if it always runs the same one, you don't need the other.[IMG]http://upload.wikimedia.org/wikipedia/commons/thumb/c/c5/Zoso.svg/744px-Zoso.svg.png[/IMG]
Looking for some good C programming tutorials for the PSP? Look no further! [URL="http://psp-coding.com/"]PSP-Coding.com[/URL] is your source for all your PSP coding needs.
-
03-11-2008, 01:11 PM #8124I'm back!

- Registriert seit
- Feb 2007
- Ort
- England
- Beiträge
- 902
- Points
- 8.236
- Level
- 61
- Downloads
- 0
- Uploads
- 0
Well I just tested the ISO idea, and again, nothing, I get error 0x8001087, the ISO works fine though because I launched it from the memory stick without issue. Next on the list, 1.50 loading

-Aura
EDIT: 1.50 doesn't work either, returns 0x80020149.Geändert von Auraomega (03-11-2008 um 01:25 PM Uhr)
-
03-11-2008, 02:22 PM #8125
Sorry to interrupt Auraomega. :o
I just have quick question as far as a fake security.
I know that there are different snippets of code for if you want to check what firmware is running, or what motherboard is being used.
I tried googling, but to no avail. Would it be possible to create something like what Sony has, where it says, "Firmware X.YZ in use, Firmware X.YZ required."
That way, I could set up my application to only be started if the user is running M33 3.90 or something like that.[QUOTE=Archaemic]
[size=1]My manwich![/size][/QUOTE]
[QUOTE=mohaas05]lol i can't say d*ck?[/QUOTE]
-
03-11-2008, 02:25 PM #8126I'm back!

- Registriert seit
- Feb 2007
- Ort
- England
- Beiträge
- 902
- Points
- 8.236
- Level
- 61
- Downloads
- 0
- Uploads
- 0
Yep, if you make something to sniff out the arguments passed to vshmain.prx you should be able to find out where this information is kept, then its a simple case of restarting the vsh with those arguments.
The specific function you'll need is sceKernelExitVSHVSH(struc t SceKernelLoadExecVSHParam *param);
Find info for it in psploadexec_kernel.h
-Aura
EDIT: That method is if you want the 100% offical look, if not, you could easily find the version of the firmware with either flash0:/vsh/resource/version.txt or by checking it using a certain function (can't remember which), and just displaying the error in the app itself, this of course looks less professional but is significantly easier.
-
03-11-2008, 02:31 PM #8127
This is kinda ticking me off..
I can't get my C++ image viewer working (I made this using the tutorial at pspprogramming.com)
The error:
The main.cpp file:Code:psp-g++ -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -I. -I/usr/local/p spdev/psp/sdk/include -O2 -G0 -Wall -fno-exceptions -fno-rtti -D_PSP_FW_VERSION= 150 -c -o main.o main.cpp psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -D_PSP_FW_VERSION= 150 -L. -L/usr/local/pspdev/psp/sdk/lib main.o graphics.o framebuffer.o -lpsp gu -lpng -lz -lm -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser -lpspkern el -o hello.elf /usr/local/pspdev/lib/gcc/psp/4.1.0/../../../../psp/bin/ld:graphics.o: file form at not recognized; treating as linker script /usr/local/pspdev/lib/gcc/psp/4.1.0/../../../../psp/bin/ld:graphics.o:1: parse e rror collect2: ld returned 1 exit status make: *** [hello.elf] Error 1
The Makefile:Code://First app #include <pspdisplay.h> #include <pspctrl.h> #include <pspkernel.h> #include <pspdebug.h> #include <pspgu.h> #include <png.h> #include <stdio.h> #include "graphics.h" PSP_MODULE_INFO("Image Displayer", 0, 1, 1); //This names the eboot in the XMB #define printf pspDebugScreenPrintf //Defines that huge printf function to just 'printf' #define MAX(X, Y) ((X) > (Y) ? (X) : (Y)) /* Exit callback */ int exit_callback(int arg1, int arg2, void *common) { sceKernelExitGame(); return 0; } /* Callback thread */ int CallbackThread(SceSize args, void *argp) { int cbid; cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL); sceKernelRegisterExitCallback(cbid); sceKernelSleepThreadCB(); return 0; } /* Sets up the callback thread and returns its thread id */ int SetupCallbacks(void) { int thid = 0; thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0); if(thid >= 0) { sceKernelStartThread(thid, 0, 0); } return thid; } int main(){ char buffer[200]; Image* ourImage; //Sets up an image class pspDebugScreenInit(); SetupCallbacks(); initGraphics(); sprintf(buffer, "ourImage.png"); ourImage = loadImage(buffer); if (!ourImage) { //Image load failed printf("Image load failed!\n"); } else { int x = 0; int y = 0; sceDisplayWaitVblankStart(); //Allows home button to work while (x < 480){ while(y < 272){ blitAlphaImageToScreen(0, 0, 32, 32, ourImage, x, y); //Prints the image to the screen at X, Y y += 32; } x+= 32; y = 0; } flipScreen(); } sceKernelSleepThread(); return 0; }
All help greatly appreciated.Code:TARGET = hello OBJS = main.o graphics.o framebuffer.o CFLAGS = -O2 -G0 -Wall CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti ASFLAGS = $(CFLAGS) LIBDIR = LIBS = -lpspgu -lpng -lz -lm LDFLAGS = EXTRA_TARGETS = EBOOT.PBP PSP_EBOOT_TITLE = Image Example PSPSDK=$(shell psp-config --pspsdk-path) include $(PSPSDK)/lib/build.mak
Atheist, because I just won't believe in what doesn't show itself to me.
-
03-11-2008, 02:37 PM #8128
Zitat von Auraomega
Thanks Aura, I will try first with the official way. The function that you mentioned is
If I were to change that to:
Would that work for checking for M33? Or should I be more specific?[QUOTE=Archaemic]
[size=1]My manwich![/size][/QUOTE]
[QUOTE=mohaas05]lol i can't say d*ck?[/QUOTE]
-
03-11-2008, 02:39 PM #8129I'm back!

- Registriert seit
- Feb 2007
- Ort
- England
- Beiträge
- 902
- Points
- 8.236
- Level
- 61
- Downloads
- 0
- Uploads
- 0
You need to compile differently for C++, your makefile should have an extra bit at the bottom:
-AuraCode:./main.o: ./main.cpp $(CXX) $(CXXFLAGS) -c ./main.cpp -o ./main.o
-
03-11-2008, 02:43 PM #8130words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
Aura - No you don't.
Simply add -lstdc++ to the libs line at the very end and your golden.
Try using this makefile:
Code:TARGET = hello OBJS = main.o graphics.o framebuffer.o CFLAGS = -O2 -G0 -Wall CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti ASFLAGS = $(CFLAGS) LIBDIR = LIBS = -lpspgu -lpng -lz -lm -lstdc++ LDFLAGS = EXTRA_TARGETS = EBOOT.PBP PSP_EBOOT_TITLE = Image Example PSPSDK=$(shell psp-config --pspsdk-path) include $(PSPSDK)/lib/build.mak

...at what speed must I live.. to be able to see you again?...
Projects
You can support my Open World 3D RPG for PSP by voting for it here


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