The above video goes away if you are a member and logged in, so log in now!

 Would you like to get all the newest Gaming News fromQJ.NET in your email each day? Want to learn more about the team who brings you the QJ news?

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; Thank you! -= Double Post =- Am I such a loser in math? I call this function Code: void drawScrollableList(list_entry ...

 Tweet
1. Thank you!
-= Double Post =-
Am I such a loser in math? I call this function

Code:
```void drawScrollableList(list_entry * list, int list_len, int selected, int selected_pos, int x, int y)
{
int i, pos;
long scroll_height, scroll_pos;
int start = selected+1 - selected_pos;
int max_items = (list_len > 13) ? 13 : list_len;

// Draw List
for(pos=0,i==start; pos<max_items; i++,pos++)
{
if(i==selected)
{
blitImageToScreen(0, 0, 225, 20, img_highlight, x, y+pos*20);
printTextScreen(x+9, y+5+pos*20, list[i].label, RGB(255,255,255));
} else {
blitImageToScreen(0, 0, 6, 11, img_arrow, x+213, y+5+pos*20);
printTextScreen(x+9, y+5+pos*20, list[i].label, RGB(0,0,0));
}
}
[...]
}```
with

Code:
```	list_entry main_menu[5];

drawScrollableList(main_menu, 5, 1, 2, 0, 6);```
To me, this should make start = 1+1-2 = 0, but he prints a list from item 1 (Videos) to 5 (cryptic chars). Why?
-= Double Post =-
This is crazy! I just changed the line
Code:
`int start = selected+1 - selected_pos;`
to
Code:
`int start = selected+1 - selected_pos-1;`
and he still prints that list from 1 to 5!
-= Double Post =-
^^ an just in the momen I switched to the the IDE I saw it's

i==start (=true=1)

not

i=start

sorry for my stupid posts

2. Code:
```\$ make kxploit
make: *** No rule to make target `graphics.o', needed by `hello.elf'.  Stop.```
#include <pspdisplay.h>
#include <pspctrl.h>
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspgu.h>
#include <png.h>
#include <stdio.h>
#include "graphics.h"

#define printf pspDebugScreenPrintf
PSP_MODULE_INFO("Image Display Program", 0, 1, 1);
/* Exit callback */
int exit_callback(int arg1, int arg2, void *common) {
sceKernelExitGame();
return 0;
}

int CallbackThread(SceSize args, void *argp) {
int cbid;

cbid = sceKernelCreateCallback(" Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCall back(cbid);

return 0;
}

/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void) {
int thid = 0;

if(thid >= 0) {
}

return thid;
}
int main()
{
char buffer[200];
pspDebugScreenInit();
SetupCallbacks();
initGraphics();
}
why is that????

3. Your error is because you don't have graphics.c in the same directory as the rest of your files.

Your code also will not display anything as is.

4. U have to add filpScreen();
int main()
{
char buffer[200];
pspDebugScreenInit();
SetupCallbacks();
initGraphics();
while (x < 480) {
while (y < 272) {
blitAlphaImageToScreen(0 ,0 ,32 , 32, menu, x, y);
y += 32;
}
x += 32;
y = 0;
}flipScreen();
}
return 0;
}
}

5. tiff sdk

how do u print something the the screan when u press X in the tiff sdk

6. You shouldnt be coding using an SDK if you cant read a library =-\

If you really want to print something, modify the Hello World tiff... No requests ;)

7. Originally Posted by SG57
You shouldnt be coding using an SDK if you cant read a library =-\

If you really want to print something, modify the Hello World tiff... No requests ;)
i know how to print something i just want it to happen when i press X

8. ...Same as 1.5 dude...:

if ( (SceCtrlData) _____ & PSP_CTRL_CROSS) {
print
}

9. kk
thancks

10. another prob

\$ make kxploit
psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -c -o main.o mai
n.c
psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -L. -L/usr/local/
pspdev/psp/sdk/lib main.o -lpspgu -lpng -lz -lm -lpspdebug -lpspdisplay -lpspg
e -lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver
-lpsputility -lpspuser -lpspkernel -o cpu
psp-fixup-imports cpu
psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -L. -L/usr/local/
pspdev/psp/sdk/lib main.o -lpspgu -lpng -lz -lm -lpspdebug -lpspdisplay -lpspg
e -lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver
-lpsputility -lpspuser -lpspkernel -o tester.elf
psp-fixup-imports tester.elf
mkdir -p "cpu tester"
psp-strip cpu tester.elf -o cpu tester/EBOOT.PBP
Usage: psp-strip <option(s)> in-file(s)
Removes symbols and sections from files
The options are:
-I --input-target=<bfdname> Assume input file is in format <bfdname>
-O --output-target=<bfdname> Create an output file in format <bfdname>
-F --target=<bfdname> Set both input and output format to <bfdname>

-p --preserve-dates Copy modified/access timestamps to the output

-R --remove-section=<name> Remove section <name> from the output
-s --strip-all Remove all symbol and relocation information
-g -S -d --strip-debug Remove all debugging symbols & sections
--strip-unneeded Remove all symbols not needed by relocations
--only-keep-debug Strip everything but the debug information
-N --strip-symbol=<name> Do not copy symbol <name>
-K --keep-symbol=<name> Only copy symbol <name>
-w --wildcard Permit wildcard in symbol comparison
-x --discard-all Remove all non-global symbols
-X --discard-locals Remove any compiler-generated symbols
-v --verbose List all object files modified
-V --version Display this program's version number
-h --help Display this output
--info List object formats & architectures supported

-o <file> Place stripped output into <file>
psp-strip: supported targets: elf32-littlemips elf32-bigmips elf64-bigmips elf64
-littlemips elf64-little elf64-big elf32-little elf32-big srec symbolsrec tekhex
binary ihex
make: *** [kxploit] Error 1
yeah , yeah , i m back programming;)

11. Your TARGET can only be one word.

Code:
`TARGET = cpu tester`
Will not work.

Code:
`TARGET = cputester`
Will work.

12. k thnx
-= Double Post =-
new problem with usb

#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspusb.h>
#include <pspusbstor.h>
#include <string.h>
// Defines
#define printf pspDebugScreenPrintf

// Functions
{
u32 startResult;
int status;

if (loadResult & 0x80000000) return -1;
else
startResult = sceKernelStartModule(load Result, 0, NULL, &status, NULL);

if (loadResult != startResult) return -2;

return 0;
}

void initUSB()
{
u32 retVal;

retVal = sceUsbStart(PSP_USBBUS_DR IVERNAME, 0, 0);

if (retVal != 0) {
printf("Error starting USB Bus driver (0x%08X)\n", retVal);
}

retVal = sceUsbStart(PSP_USBSTOR_D RIVERNAME, 0, 0);
if (retVal != 0) {
printf("Error starting USB Mass Storage driver (0x%08X)\n", retVal);
}

retVal = sceUsbstorBootSetCapacity (0x800000);
if (retVal != 0) {
printf("Error setting capacity with USB Mass Storage driver (0x%08X)\n", retVal);
}

retVal = 0;
}

void usbMode(const char* what)
{
u32 retVal;

if (stricmp(what, "on")==0) {
retVal = sceUsbActivate(0x1c8);
}
else if (stricmp(what, "off")==0) {
retVal = sceUsbDeactivate(0);
}
}
int main()
{
initUSB();//aanzetten
usbMode("on");
}
isn't compilling because this errors
\$ make kxploit
psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -L. -L/usr/local/
pspdev/psp/sdk/lib main.o -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk
-lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspus
main.o: In function `initUSB':
main.c.text+0xb0): undefined reference to `sceUsbStart'
main.c.text+0xd4): undefined reference to `sceUsbStart'
main.c.text+0xec): undefined reference to `sceUsbstorBootSetCapacit y'
main.o: In function `usbMode':
main.c.text+0x18c): undefined reference to `sceUsbActivate'
main.c.text+0x1bc): undefined reference to `sceUsbDeactivate'
collect2: ld returned 1 exit status

13. Can you try renaming your .cpp with .c and see if that fixes any errors. I highly doubt it but the PSP libraries may be for just pure C and hve no support for C++ (ie #ifdef __cplusplus extern C { #endif )

http://www.parashift.com/c++-faq-lit...c-and-cpp.html

btw i just copied from the topic c examples;)

15. Oh.. I thought the smileys were pp's . In that case, you are not linking to the libraries for the usb functions.

@head54_us: The SDK does support C++, by using exactly the same method you described.

17. id did that(if you mean in the makefile) already ;) not working

18. Your output from cygwin says not:

Code:
```-lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk
-lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspus
I don't see either of the USB libraries there.

19. Hey everyone, im a total NOOOOB at programming, but i really wanna learn. So i started on a Hello World........which probably has over 20 errors. and when i try to compile with cygwin, it said that there is no kernal.h in its library.....but i did indeed install psptoochain. Anyways heres my code. can anyone help me thanks

Code:
```//Hello World - My first PSP Program
/*
This program was created by me on October 21 2006
It is a simple Hello World Application
*/

#include <pspkernal.h>
#include <pspdebug.h>

PSP_MODLUE_INFO("Hello World", 0,1,1);

#define printf pspDebugScreenPrintf

/* Exit callback */

int exit_callback(int arg1, int arg2, void *common) {
sceKernalExitGame();
return 0;
}

int CallbackThread(SceSize args, void *argp) {
int cbid;

cbid = sceKernalCreateCallback("Exit Callback", exit_callback, NULL);

return 0;
}

int SetupCallbacks(void) {
int thid+ 0;

if(thid >=0) {

}

return thid;
}

//to end a line a semi colon is needed, not sure what these two blocks of code do...

pspDebugScreenInit();
SetupCallbacks();

//this prinnts Hello World to the screen

printf("Hello World i AM HERE")

//this is to make the printf appear, becuase it will just erase without it

return 0;
}```

20. Could you post the exact output that cygwin gives you please?

Hint: Right-click on cygwin's titlebar, select edit, select mark (the top choice), mark the text you want to copy, open up the titlebar menu again and select edit then copy. Now the text you marked is on your clipboard, so simply paste it here ;)

21. Code:
`PSP_MODLUE_INFO("Hello World", 0,1,1);`
Should be:

Code:
`PSP_MODULE_INFO("Hello World", 0,1,1);`
Code:
`int thid+ 0;`
Should be:

Code:
`int thid = 0;`
Code:
`printf("Hello World i AM HERE")`
Requires a semi-colon at the end:

Code:
`printf("Hello World i AM HERE");`
All your references to kernal should be kernel

You're also missing:

Code:
```int main()
{```
before your 'printf("Hello World i AM HERE")' line.

There's probably more if I looked closer.

22. OMG HAHAH.....my spelling sucks poop......my bad.....cheesh kernEl... thanks.

\$ make kxploit
psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -02-GO-Wall -c -o main.o main.
c
psp-gcc: unrecognized option '-02-GO-Wall'
main.c:7:23: error: pspkernal.h: No such file or directory
main.c:10: error: syntax error before string constant
main.c:10: warning: data definition has no type or storage class
main.c:22: error: syntax error before 'args'
main.c: In function 'SetupCallbacks':
main.c:34: error: syntax error before '+' token
main.c:36: error: 'thid' undeclared (first use in this function)
main.c:36: error: (Each undeclared identifier is reported only once
main.c:36: error: for each function it appears in.)
main.c: At top level:
main.c:49: error: conflicting types for 'pspDebugScreenInit'
/usr/local/pspdev/psp/sdk/include/pspdebug.h:32: error: previous declaration of
'pspDebugScreenInit' was here
main.c:49: warning: data definition has no type or storage class
main.c:50: warning: data definition has no type or storage class
main.c:55: error: syntax error before string constant
main.c:59: warning: data definition has no type or storage class
main.c:61: error: syntax error before 'return'
make: *** [main.o] Error 1

Thanks

Edit after making those adjustments insomniac posted i got this in cygwin

\$ make kxploit
psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -02-GO-Wall -c -o main.o main.
c
psp-gcc: unrecognized option '-02-GO-Wall'
main.c:49: error: conflicting types for 'pspDebugScreenInit'
/usr/local/pspdev/psp/sdk/include/pspdebug.h:32: error: previous declaration of
'pspDebugScreenInit' was here
main.c:49: warning: data definition has no type or storage class
main.c:50: warning: data definition has no type or storage class
make: *** [main.o] Error 1

23. Code:
`psp-gcc: unrecognized option '-02-GO-Wall'`
That line in your makefile should be:

Code:
`-O2 -G0 -Wall`
That's (Letter)O 2, -G Zero, -Wall.

You also need to make sure that the pspDebugScreenInit(); line and the SetupCallbacks(); line are AFTER the:

Code:
```int main()
{```

24. THANK YOU IT COMPILED. and my psp actually sees it. can anyone please help me, i wanna print something to screen, and then like go to the next line when the sentence was unfinished like

this. thanks

25. You can do something like this:

Code:
`printf("This is line 1\nThis is line 2\nThis is line 3\n");`
Or even this:

Code:
```printf("This is line 1\n");
printf("This is line 2\n");
printf("This is line 3\n");```

26. print X

sg57 when i do it is says error: ____ undeclared

or something like that

27. You have to replace ____ with an SceCtrlData struct you know... <_<

28. Originally Posted by homer
You have to replace ____ with an SceCtrlData struct you know... <_<
whats a struct and wich one should i choose

29. Insomniac, what does the n in 1/n, 2/n mean? trying it now. thhanks

edit: does not work xD. any other suggestions?

30. Sethis - '\n' character is *nix for 'carraige return' or 'newline'. so putting \n anywhere in a string when printingwill cause whatever is after that to go to the line below (approx. 10 pixels down...)

psp-freak222 -
Code:
```#include <pspctrl.h>

...

...

if ( pad.Buttons & PSP_CTRL_CROSS) {
print
}```

Page 49 of 340 First ... 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 99 149 ... Last

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

All times are GMT -8. The time now is 09:48 AM.

Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY