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; Zitat von slicer4ever edit: and lastly, my post wasn't pointless, do you only take the most negative thing in a ...
-
01-19-2009, 12:06 PM #9541I'm back!

- Registriert seit
- Feb 2007
- Ort
- England
- Beiträge
- 902
- Points
- 8.236
- Level
- 61
- Downloads
- 0
- Uploads
- 0
Because its another post that you've given no real advice only said that its stupid, as I said you never explained why, if someone is wanting to use that method they obviously think its a good idea and giving them some real proof as to why its stupid would be better than just coming out with it and having no evidence.
I'd like to see though how you get this bit:
What other times have I ever looked at a post and made it appear negative without good reason? As I said, there was NOTHING constructive about your post at all, it held no real help just a blatent "this is stupid" remark to it. Yes this is negative in my opinion because its a help thread and you just appear to be throwing your knowledge around without offering advice or showing where people make their mistakes. It wouldn't have been difficult to have compiled your second post into your first and avoid my comment. A help thread is for help.
-Aura
-
01-19-2009, 01:08 PM #9542QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
if it's the effect he's going after, than it doesn't require the use of the CLUT, but just manipulation of the data field inside of OSL_IMAGE, trying to use the CLUT for the same effect, which yes is pretty intresting, is alot of waste of code
@aura, i could have gone about it at a nicer way indeed1. 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
-
01-19-2009, 02:57 PM #9543xMod.
- Registriert seit
- Oct 2008
- Ort
- Melbourne, Australia
- Beiträge
- 675
- Points
- 4.576
- Level
- 43
- My Mood
-
- Downloads
- 0
- Uploads
- 0
guys im having some trouble...
how can i fix:
?Code:$ ./toolchain.sh 3 6 ERROR: Add C:/PSP/pspdev/bin to your path before continuing. ../depends/check-pspdev.sh: Failed.
~!SlasheR!~
-
01-19-2009, 03:07 PM #9544QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
did u even google your problem?
googled: ERROR: Add C:/PSP/pspdev/bin to your path before continuing.
2 results, second one:
http://ubuntuforums.org/showthread.php?t=554423
solution:
export PATH=$PATH:/usr/local/pspdev/bin
before you run the toolchain
IIRC, doing that is in the readme of the tootchain as well as another command you have to do in bash first, maybe checking the readme would help to1. 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
-
01-19-2009, 03:17 PM #9545xMod.
- Registriert seit
- Oct 2008
- Ort
- Melbourne, Australia
- Beiträge
- 675
- Points
- 4.576
- Level
- 43
- My Mood
-
- Downloads
- 0
- Uploads
- 0
slicer i did google,
my pspdev folder is actuallt located at C:\psp\pspdev\
so i do:
?Code:export PATH=$PATH:C:\\psp\\pspdev\\
~!SlasheR!~
-
01-19-2009, 03:27 PM #9546QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
psptoolchain readme:
specifically "How do i use?" number 2.
Zitat von readme
try it before u ask again please1. 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
-
01-19-2009, 03:33 PM #9547xMod.
- Registriert seit
- Oct 2008
- Ort
- Melbourne, Australia
- Beiträge
- 675
- Points
- 4.576
- Level
- 43
- My Mood
-
- Downloads
- 0
- Uploads
- 0
ok srry i thought becuase i installed in dif location!
THX!!!
~!SlasheR!~
-
01-19-2009, 04:35 PM #9548I'm back!

- Registriert seit
- Feb 2007
- Ort
- England
- Beiträge
- 902
- Points
- 8.236
- Level
- 61
- Downloads
- 0
- Uploads
- 0
I posted this earlier but I've done some extra work now (check the bottom)
I'm having an annoying compiler issue with some code of mine...
makefile:
main.cpp:Code:... OBJS =\ PBPDepack.o\ ...
depack.h:Code:#include "depack.h" ... FILE *fp; fp = fopen("ms0:/test.pbp", "r"); long int one = 0; long int two = 0; getOffsets(fp, 0, &one, &two); fclose(fp);
PBPDepack.s:Code:#include <stdio.h> void getOffsets(FILE *pbp, int position, long int *pointerStart, long int *pointerEnd);
Error:Code:.set noreorder #include "pspstub.s" STUB_START "PBPDepack",0x40090000,0x00010005 STUB_FUNC 0x5FF3D8D7,getOffsets STUB_END
No idea what is going on, its not exclusive to PBPDepack either, I've tried a couple of modules and exports, all giving the same problem that its undefined. Anyone know whats going on here?main.o: In function `loadOption(int)':
...:381: undefined reference to `getOffsets(
__sFILE*, int, long*, long*)'
*
I've attempted to use a "wrapper" function in a c file, as I've noticed errors compiling modules in cpp I wondered if linking to a c file and running would work - epic fail. Same error as above with the wrapper function (I.E. the function in the c file) although strangely the wrapper file compiled fine :Argh:
I compiled the exact same code on my Ubuntu setup, which as an up-to-date toolchain, sdk, etc (my PC is running on maybe 18 month old one). The same thing occurs on there, same error everything.
I attempted to change my cpp file to c but seeing as I'm using lots of class functions it'd be very time consuming to get it compiling in c and calling on c++ files, although I'm certain this would work its just not worth the effort.
Is there anything that needs adding to the makefile to compile c++ files correctly without this onslaught of random errors? I've included -lstdc++ but its not made any difference that I can see.
*
-Aura
-
01-19-2009, 05:42 PM #9549QJ Gamer Blue
- Registriert seit
- Jul 2007
- Beiträge
- 296
- Points
- 3.795
- Level
- 38
- Downloads
- 0
- Uploads
- 0
Try:
MyCppFile.cpp
That is if myCFunc() is in a file that is compiled as a C file, and not a C++ file.Code:extern "C" { #include "MyCFile.h" } int myCppFunc() { return myCFunc(); }
-
01-19-2009, 06:50 PM #9550xMod.
- Registriert seit
- Oct 2008
- Ort
- Melbourne, Australia
- Beiträge
- 675
- Points
- 4.576
- Level
- 43
- My Mood
-
- Downloads
- 0
- Uploads
- 0
i did ./toolchain 3 6 and left it for an hour when i came back it hadnt finished but it stopped and said
what wrong??Code:make: *** [all] Error 2 ../scripts/006-pspsdk-stage2.sh: Failed.
~!SlasheR!~
-
01-19-2009, 07:44 PM #9551QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
that's the only thing it outputed?
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
-
01-20-2009, 02:12 AM #9552Bush Programmer

- Registriert seit
- Nov 2005
- Beiträge
- 3.658
- Points
- 60.149
- Level
- 100
- Downloads
- 0
- Uploads
- 0
Hi Guys,
Trying to grab a colour screen and convert it to black & white, and write that to an image.
Something wrong here.. any ideas?
The image is b&W, but some bright colours turn out really dark.void blackwhite() {
u8 b; u8 g; u8 r; int xxx;
for (pxx=0; pxx<480; pxx++) { // image width
for (pyy=0; pyy<272; pyy++) { // image height
pixel = getPixelScreen(pxx, pyy);
r = pixel & 0xFF;
g = (pixel & 0xFF00) >> 8;
b = (pixel & 0xFF0000) >> 16;
xxx = r + b + g;
pixel = xxx * 0x10000;
pixel = pixel + (xxx * 0x100);
pixel = pixel + xxx;
putPixelImage(pixel,pxx,p yy,bwscreen);
}}
}
Oh yeah.. the idea is to add the values of R,G & B, then divide that by three for each pixel.
Then write that value back to R,G & B for the greyscale colour.
-
01-20-2009, 03:12 AM #9553QJ Gamer Blue
- Registriert seit
- Sep 2005
- Ort
- Chigasaki, Japan
- Beiträge
- 226
- Points
- 4.980
- Level
- 45
- Downloads
- 0
- Uploads
- 0
You may get an overflow by adding all three components (e.g. 3x255). Also, for RGB to gray scale conversion you should use weights for the components, IIRC gray = .3 * r + .59 * g + .11 * b (I could be wrong, has been a while). To be safe you should clip the values against [0..255].
HTH
-
01-20-2009, 04:57 AM #9554I'm back!

- Registriert seit
- Feb 2007
- Ort
- England
- Beiträge
- 902
- Points
- 8.236
- Level
- 61
- Downloads
- 0
- Uploads
- 0
Thanks _dysfunctional that worked, I feel a bit stupid now because I've done this in the past but completely forgot about it :o
-Aura
-
01-20-2009, 09:08 AM #9555QJ Gamer Green
- Registriert seit
- Aug 2008
- Ort
- Cyprus
- Beiträge
- 48
- Points
- 5.495
- Level
- 47
- Downloads
- 0
- Uploads
- 0
Hi, I've just started PSP programming, and I have a problem.
I'm trying to display an image, but the application seems to skip lines and go directly to sceKernelSleepThread!
Never mind about those printf's, i just used them to see the app's flow. Ikona is declared as blitAlphaImagetoScreen. The problem is loadimage, for whatever reason. Getkey() is also a function I wrote.Code:int main(){ SceCtrlData reqpad; char imgadr[20]; Image* loamg; pspDebugScreenInit(); SetupCallbacks(); initGraphics(); printf("press x"); reqpad.Buttons = PSP_CTRL_CROSS; getkey(reqpad); printf("exit"); sprintf(imgadr,"imgi.png"); printf("www"); // ---Skips here loamg = loadImage(imgaddr); printf("xc"); ikona(0,0,480,272,loamg,0,0); printf("ikona"); flipScreen(); sceKernelSleepThread(); return 0; }
Can someone help me? Thanks.
-
01-20-2009, 09:24 AM #9556QJ Gamer Green
- Registriert seit
- Apr 2008
- Ort
- in a hobbit hole
- Beiträge
- 67
- Points
- 6.366
- Level
- 52
- Downloads
- 0
- Uploads
- 0
In this case, it might be heplful to check if loadImage() is returning NULL. If so, then it may be a problem with the path.The problem is loadimage, for whatever reason
See? You declare imgadr but you pass imgaddr to the function. I'd be surprised if you didn't get any errors compiling.Code:... char imgadr[20]; ... sprintf(imgadr,"imgi.png"); printf("www"); // ---Skips here loamg = loadImage(imgaddr);
Also, I don't see any reason to use sprintf when your just writing a plain string to a buffer.
Code:sprintf(imgadr,"imgi.png");
-
01-20-2009, 09:33 AM #9557QJ Gamer Green
- Registriert seit
- Aug 2008
- Ort
- Cyprus
- Beiträge
- 48
- Points
- 5.495
- Level
- 47
- Downloads
- 0
- Uploads
- 0
I tried checking for NULL, but it seems that it's correct.
I've also entered a plain string to loadImage, but it still gets stuck there.
-
01-20-2009, 10:07 AM #9558I'm back!

- Registriert seit
- Feb 2007
- Ort
- England
- Beiträge
- 902
- Points
- 8.236
- Level
- 61
- Downloads
- 0
- Uploads
- 0
You said it skips to the sleep function, but do you get output with printf? And have you tried blitImage instead of blitAlphaImage, the alpha can sometimes have problems so it'd be a 1 time check to see if that changes anything.
Also, for safety add a check that the image loads as standard (even if it loads now, someone might not copy the file or whatever in the future) and hard code the path instead of using a buffer as its just a waste of code.
Whats in Getkey()? Experiance also tells me that doing reqpad.Buttons = PSP_CTRL_CROSS; won't have the effect you want it to.
-Aura
-
01-20-2009, 10:39 AM #9559QJ Gamer Green
- Registriert seit
- Aug 2008
- Ort
- Cyprus
- Beiträge
- 48
- Points
- 5.495
- Level
- 47
- Downloads
- 0
- Uploads
- 0
Getkey is just a function that ends when a specified button is pressed and released. That reqpad.Buttons = PSP_CTRL_CROSS actually works for me, at least using the X button.
From other tests I have come to realise it stops at loadimage. Perhaps I should take a look with the address or something.Code:void getkey(SceCtrlData butid){ SceCtrlData pad,lastpad; while (1){ sceCtrlReadBufferPositive(&pad, 1); if (lastpad.Buttons != pad.Buttons){ if (pad.Buttons & butid.Buttons){ return; lastpad.Buttons = pad.Buttons; } else{ lastpad.Buttons = 0;} } } }
-
01-20-2009, 11:26 AM #9560I'm back!

- Registriert seit
- Feb 2007
- Ort
- England
- Beiträge
- 902
- Points
- 8.236
- Level
- 61
- Downloads
- 0
- Uploads
- 0
Does it sleep or crash? Have you tried running it inside PSPLink? You may be better able to pinpoint the time of the problem inside there.
If it crashes post the picture on here as that may be the cause.
-Aura
-
01-20-2009, 11:34 AM #9561QJ Gamer Green
- Registriert seit
- Aug 2008
- Ort
- Cyprus
- Beiträge
- 48
- Points
- 5.495
- Level
- 47
- Downloads
- 0
- Uploads
- 0
When it displays te "www" I can use the home button and exit to the XMB, only that it doesn't, it crashes. I'll try PSPLink.
EDIT: Btw, can you tell me more specifically what to do with PSPLink? I've installed and managed to connect it with usbhostfs_pc.exe, but I'm sleepy, can't figure out what to do next.
I'll also try using another image.Geändert von kostakis (01-20-2009 um 12:10 PM Uhr) Grund: Avoiding sequential posts
-
01-20-2009, 01:12 PM #9562I'm back!

- Registriert seit
- Feb 2007
- Ort
- England
- Beiträge
- 902
- Points
- 8.236
- Level
- 61
- Downloads
- 0
- Uploads
- 0
Once you've got it loaded as well as the PC side shell you type in stuff and PSPLink will make the PSP do other stuff... yay my powers of explaination are amazing.
Example, typing project4.prx would load Project4 for me from the current working directory, modlist would list the modules loaded, reset vsh would reset the vsh mode. The real beauty comes in crashes where it actually outputs something useful for you and printf commands print to the shell... which leads me to another point.
[RANT]
Never use #define because:
A) When people read your code its next to impossible to see whats going on.
B) You may make functions useless, for example pspDebugScreenPrintf to printf just removed the ability to use printf with PSPLink.
[/RANT]
When in the shell you can type help to get a list of 5 main options, then help [option] to see more info on things... help module for example gives a list of functions available that work with modules, either reading, loading, stopping, sleeping... whatever its all there.
PSPLink = God of PSP debugger software imho.
-Aura
-
01-20-2009, 01:15 PM #9563QJ Gamer Blue
- Registriert seit
- Nov 2007
- Beiträge
- 29
- Points
- 2.981
- Level
- 33
- Downloads
- 0
- Uploads
- 0
I would just say "thank you" and that would finish it, but then, there's more problems with the CLUT.
So, using the provided solution, which helped me, thanks, copied it into two functions, initClut and drawClut, which are in the "working" section of the attachment.
They work perfectly, as you can see when compiling it.
Then, i moved these two functions to the Class, map it's name, and now it doesn't work at all. The graphics are all scrawny, out of sync. i double checked, the functions are LITERALLY the same, and the makefile also contains the same flags.
And now i'm in the dark. Why, and what shall be done in order to repair it?
-
01-20-2009, 05:40 PM #9564QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
To clarify:
Don't use #define for constants if you are using C++ (with C you haven't got much of a choice).
Don't use #define to give an alias to a function, class, variable or struct name unless there is good reason to.
There will be times where using a #define is a valid choice.[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]
-
01-20-2009, 08:21 PM #9565
Such as if you're trying to build a program for multi-platform release.
I made a program a long time ago which was compiled both for PSP and PC. It contained code which was related only to to the PSP or the PC. I used defines to block out platform-specific code, so I didn't have to make separate projects to work concurrently when I chose which version to compile.GameSnooper - Random drawing of gaming news
The 32 Bit Shell - My development blog (also includes gaming oddities)
-
01-20-2009, 08:30 PM #9566xMod.
- Registriert seit
- Oct 2008
- Ort
- Melbourne, Australia
- Beiträge
- 675
- Points
- 4.576
- Level
- 43
- My Mood
-
- Downloads
- 0
- Uploads
- 0
very valid to me

~!SlasheR!~
-
01-21-2009, 01:43 AM #9567I'm back!

- Registriert seit
- Feb 2007
- Ort
- England
- Beiträge
- 902
- Points
- 8.236
- Level
- 61
- Downloads
- 0
- Uploads
- 0
Sorry yaustar, I didn't make that very clear, sometimes #define is required but as a general rule it can be avoided.
JustChris meant using something like this:
Then you can either define at the top #define __PC__ or compile with the __PC__ flag I believe in the makefile?Code:#ifdef __PC__ //PC Specific code here #endif #ifdef __PSP__ //PSP Specific code here #endif #ifdef __OTHER__ //Other Specific code here #endif
As for consts in C, can't you use const int blah = 0; or whatever as a global or does that only work in C++?
-Aura
-
01-21-2009, 04:41 AM #9568QJ Gamer Green
- Registriert seit
- Aug 2008
- Ort
- Cyprus
- Beiträge
- 48
- Points
- 5.495
- Level
- 47
- Downloads
- 0
- Uploads
- 0
OK, I've managed to overcome my n00b status
And I got the error we were looking for:
Code:libpng error: Too many IDAT's found
Geändert von kostakis (01-21-2009 um 05:23 AM Uhr)
-
01-21-2009, 04:50 AM #9569QJ Gamer Bronze

- Registriert seit
- Aug 2007
- Ort
- Australia
- Beiträge
- 659
- Points
- 8.045
- Level
- 60
- Downloads
- 0
- Uploads
- 0
-
01-21-2009, 12:30 PM #9570QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]


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