QJ.NET | Videos | Forums | iPhone | MMORPG | Nintendo DS | Wii | PlayStation 3 | PSP | Xbox 360 | PC | Downloads | Contact Us
Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact

QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides

Go Back   QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides > Developers Corner > PSP Development, Hacks, and Homebrew > PSP Development Forum
The above video goes away if you are a member and logged in, so log in now!

coding/programming help..

This is a discussion on coding/programming help.. within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; In C, how do you clear the screen, define RGB, and display the current dir?...

Reply
 
LinkBack Thread Tools
Old 10-04-2006, 01:23 PM   #1
likes kittens....awww....
 
Join Date: Sep 2006
Real First Name: Erik
Location: Detroit
Just Played: Call of Duty:World at War
Posts: 628
Trader Feedback: 0
Cool coding/programming help..

In C, how do you clear the screen, define RGB, and display the current dir?
psphacker12. is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-04-2006, 01:30 PM   #2
 
 
Join Date: Jul 2005
Location: Brampton
Posts: 631
Trader Feedback: 0
Default

pspDebugScreenClear();

if your using the normal debug txt.
and to display your current file structure???? i dont know
__________________
[CENTER]You can hyperlink quotes and the whole box will be a link:
[URL=http://forums.qj.net/showthread.php?t=35215][COLOR=DarkRed][QUOTE=ANTONIO_424][CENTER][COLOR=DarkRed]Go for it, and remember, video tape every moment...........I gotta see this :D[/COLOR][/CENTER][/QUOTE][/COLOR][/URL][SIZE=1][B][U][URL=http://forums.qj.net/showthread.php?t=65979]A Ultimate QJ FAQ[/URL][/U][/B]-[B][U][URL=http://forums.qj.net/search.php?do=finduser&u=13500]Topics I'm in[/URL][/U][/B]-[B][U][URL=http://forums.qj.net/f-psp-development-forum-11/t-pps-game-66613.html]My qj game topic[/URL][/U][/B]-[B][U][URL=http://www.psp-programming.com/dev-forum/viewtopic.php?t=962]My psp-prog topic[/URL][/U][/B]-[B][U][URL=http://files.pspupdates.qj.net/cgi-bin/cfiles.cgi]Old QJ Download site[/URL][/U][/B]-[B][U][URL=http://forums.qj.net/showthread.php?t=46926]Only ISO topic[/URL][/U][/B][/SIZE]
"You stayed up all night trying to make your psp crash? LOLOL!!" - my brother
My PSN name is "icantthinkofone".[/CENTER]
lord pip is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-04-2006, 01:33 PM   #3

OMFG
 
Slasher's Avatar
 
Join Date: Jul 2005
Location: Toronto
Posts: 2,816
Trader Feedback: 0
Default

By 'clearing the screen' it depends how you setup your framebuffer, etc. If you're just using the default graphics.c/h then it would be flipScreen(); , or perhaps clearScreen(0);

Code:
#define RGB(r, g, b) (0xFF000000 | ((b)<<16) | ((g)<<8) | (r))
http://slasher.team-duck.com then scroll down to filebrowser?
Or if you mean just getting the current dir, it would be
Code:
char path[255];
getcwd(path, 255);
Slasher is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-04-2006, 03:04 PM   #4
likes kittens....awww....
 
Join Date: Sep 2006
Real First Name: Erik
Location: Detroit
Just Played: Call of Duty:World at War
Posts: 628
Trader Feedback: 0
Default

Quote:
Originally Posted by Slasher
By 'clearing the screen' it depends how you setup your framebuffer, etc. If you're just using the default graphics.c/h then it would be flipScreen(); , or perhaps clearScreen(0);

#define RGB(r, g, b) (0xFF000000 | ((b)<<16) | ((g)<<8) | (r))

http://slasher.team-duck.com then scroll down to filebrowser?
thanks guys I wanted to know how to define RGB so i could change the color of my text LOL
-= Double Post =-
how do you define a null variable??

Last edited by psphacker12.; 10-04-2006 at 03:04 PM.. Reason: Automerged Doublepost
psphacker12. is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-04-2006, 03:15 PM   #5

sceKernelExitGame();
 
Bronx's Avatar
 
Join Date: Jan 2006
Location: New York
Posts: 3,125
Trader Feedback: 0
Default

bool variable = NULL;

I believe that would work, but I always get confused with the bools and NULL and nil and flase and true
Bronx is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-04-2006, 03:29 PM   #6

Developer
 
yaustar's Avatar
 
Join Date: Jun 2006
Location: UK
Posts: 2,317
Trader Feedback: 0
Default

You can't define a NULL variable (not in the literal sense). You can initialise the base datatypes (int, float, double, bool, etc) to 0 or a default value of your choosing. You can NULL a pointer so that it points to 'nothing' by:
Code:
int * pOddVariableName = NULL; // pointer is now NULLed
pOddVariableName = NULL; // Or can assign the value to an existing pointer
NULL is normally #define as 0 in one of the common header files that you can include that comes with the compiler. Bear in mind this well NOT free memeory in the same way as Lua. Lua has 'garbarge collection' (keyword, google it) where as C/C++ does not.
Code:
// Let's see if I can remember some C
int * pNumber = malloc( sizeof(int) ); // Allocated 4 bytes on the heap
*pNumber = 10; // Given it a value for the hell of it
pNumber = NULL; // Does not free the memory on the heap
*pNumbr = 13; // Runtime NULL exception error. Tried to give a value to 'nothing'
Code:
// Let's see if I can remember some C
int * pNumber = malloc( sizeof(int) ); // Allocated 4 bytes on the heap
*pNumber = 10; // Given it a value for the hell of it
free( pNumber ); // Freed the memory on the heap
*pNumber = 13; // Runtime exception error because the memory that the pointer was pointing to is now free so the program can't assign the value
pNumber = NULL; // Always NULL your pointers when you free them. Bugs are a lot easier to track this way.
yaustar is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-04-2006, 03:51 PM   #7
likes kittens....awww....
 
Join Date: Sep 2006
Real First Name: Erik
Location: Detroit
Just Played: Call of Duty:World at War
Posts: 628
Trader Feedback: 0
Default

how do you change the text color with RGB??
I know you use,
Code:
pspDebugSetTextColor();
but how do you use RGB text?
psphacker12. is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-04-2006, 05:46 PM   #8

...in a dream...
 
SG57's Avatar
 
Join Date: Jul 2005
Posts: 4,957
Trader Feedback: 0
Default

psphacker12 - Plesae use the appropraite thread for this. Also, there are plenty of converters out there... The links on the bottom of this site give you lots of resources...

http://www.colortools.net/article_web_colors.html
__________________
SG57 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-05-2006, 06:20 PM   #9
 
 
Join Date: Jul 2005
Location: Brampton
Posts: 631
Trader Feedback: 0
Default

http://www.psp-programming.com/tutorials/c/lesson05.htm

this little sample will doo all the colours you want.
with all the txt and background colours you want.
__________________
[CENTER]You can hyperlink quotes and the whole box will be a link:
[URL=http://forums.qj.net/showthread.php?t=35215][COLOR=DarkRed][QUOTE=ANTONIO_424][CENTER][COLOR=DarkRed]Go for it, and remember, video tape every moment...........I gotta see this :D[/COLOR][/CENTER][/QUOTE][/COLOR][/URL][SIZE=1][B][U][URL=http://forums.qj.net/showthread.php?t=65979]A Ultimate QJ FAQ[/URL][/U][/B]-[B][U][URL=http://forums.qj.net/search.php?do=finduser&u=13500]Topics I'm in[/URL][/U][/B]-[B][U][URL=http://forums.qj.net/f-psp-development-forum-11/t-pps-game-66613.html]My qj game topic[/URL][/U][/B]-[B][U][URL=http://www.psp-programming.com/dev-forum/viewtopic.php?t=962]My psp-prog topic[/URL][/U][/B]-[B][U][URL=http://files.pspupdates.qj.net/cgi-bin/cfiles.cgi]Old QJ Download site[/URL][/U][/B]-[B][U][URL=http://forums.qj.net/showthread.php?t=46926]Only ISO topic[/URL][/U][/B][/SIZE]
"You stayed up all night trying to make your psp crash? LOLOL!!" - my brother
My PSN name is "icantthinkofone".[/CENTER]
lord pip is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-06-2006, 01:42 PM   #10
likes kittens....awww....
 
Join Date: Sep 2006
Real First Name: Erik
Location: Detroit
Just Played: Call of Duty:World at War
Posts: 628
Trader Feedback: 0
Default

I'm trying to compile this..
Spoiler for Code:
Code:
#include <pspdisplay.h>
#include <pspgu.h>
#include <pspkernel.h>
#include <pspctrl.h>
#include <pspdebug.h>
#include <stdlib.h>
#include <stdio.h>
#include "graphics.h"
#define printf pspDebugScreenPrintf
#define dprint pspDebugScreenPrintf
PSP_MODULE_INFO("???", 0, 1, 1);

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);
          sceKernelRegisterExitCallback(cbid);

          sceKernelSleepThreadCB();

          return 0;
}

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(void)  {
          pspDebugScreenInit();
          SetupCallbacks();
          SceCtrlData pad;
          initGraphics();
          sceCtrlSetSamplingCycle(0);
          sceCtrlPeekBufferPositive(&pad, 1);
while (1)  {
          char buffer[200]
          int rand() {
            bool rn0 = 0;
            if (pad.Buttons != 0){
              if(pad.Buttons & PSP_CTRL_CROSS) {
                rn0=rand()%10000;
              }
            }
          if (rn0 != 0) {
            pspDebugScreenPrintf("Press 'X' to start.",);
          }
          pspDebugScreenSetXY(0, 2);
          pspDebugScreenClear();
          fillScreenRect(RGB(255, 0, 0), 0, 0, 480, 272);
          pspDebugScreenSetTextColor(0x00000000);
          pspDebugScreenPrintf("Generated Integer:%d",rn0);
          }
          sceDisplayWaitVblankStart();
          sceKernelSleepThread();
          }
return 1;
}

and I get these errors,
Spoiler for Errors:
Code:
Dave@PREFERRE-FA8B50 ~
$ cd /pspdev

Dave@PREFERRE-FA8B50 /pspdev
$ make
psp-gcc -I. -I/usr/psp/sdk/include -O2 -G0 -Wall   -c -o main.o main.c
main.c : In function 'main':
main.c(49) : error: syntax error before 'bool'
main.c(52) : error: 'rn0' undeclared (first use in this function)
main.c(52) : error: (Each undeclared identifier is reported only once
main.c(52) : error: for each function it appears in.)
main.c(56) : error: syntax error before ')' token
make: *** [main.o] Error 1

Dave@PREFERRE-FA8B50 /pspdev
$
psphacker12. is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-06-2006, 02:18 PM   #11

I'm Baaaack!
 
Access_Denied's Avatar
 
Join Date: May 2006
Location: Waukegan,Illinois
Posts: 2,185
Trader Feedback: 0
Default

Well, I just took a quick look at your error, and it amazes me you couldn't figure out that last one. It says error before ')' in line 56. Go to line 56 and you'll notice that you put this:

",);

Take out the comma. I don't know how you couldn't figure that one out.
__________________
Access_Denied is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-06-2006, 02:27 PM   #12
likes kittens....awww....
 
Join Date: Sep 2006
Real First Name: Erik
Location: Detroit
Just Played: Call of Duty:World at War
Posts: 628
Trader Feedback: 0
Default

Quote:
Originally Posted by ARza
Well, I just took a quick look at your error, and it amazes me you couldn't figure out that last one. It says error before ')' in line 56. Go to line 56 and you'll notice that you put this:

",);

Take out the comma. I don't know how you couldn't figure that one out.
I know but even after I fixed that error but even after that error it gives me this
Code:
Dave@PREFERRE-FA8B50 ~
$ cd /pspdev

Dave@PREFERRE-FA8B50 /pspdev
$ make
psp-gcc -I. -I/usr/psp/sdk/include -O2 -G0 -Wall   -c -o main.o main.c
main.c : In function 'main':
main.c(48) : error: syntax error before 'bool'
main.c : In function 'rand':
main.c(52) : error: 'rn0' undeclared (first use in this function)
main.c(52) : error: (Each undeclared identifier is reported only once
main.c(52) : error: for each function it appears in.)
main.c : In function 'main':
main.c(67) : error: syntax error at end of input
make: *** [main.o] Error 1

Dave@PREFERRE-FA8B50 /pspdev
$
psphacker12. is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-07-2006, 06:07 AM   #13
 
Join Date: Aug 2006
Location: Sydney, Australia
Posts: 56
Trader Feedback: 0
Default

Quote:
Originally Posted by psphacker12.
I'm trying to compile this..
Code:
while (1)  {
          char buffer[200]
          int rand() {
            bool rn0 = 0;
            if (pad.Buttons != 0){
              if(pad.Buttons & PSP_CTRL_CROSS) {
                rn0=rand()%10000;
              }
            }
          if (rn0 != 0) {
            pspDebugScreenPrintf("Press 'X' to start.",);
          }
          pspDebugScreenSetXY(0, 2);
          pspDebugScreenClear();
          fillScreenRect(RGB(255, 0, 0), 0, 0, 480, 272);
          pspDebugScreenSetTextColor(0x00000000);
          pspDebugScreenPrintf("Generated Integer:%d",rn0);
          }
          sceDisplayWaitVblankStart();
          sceKernelSleepThread();
          }
return 1;
}
and I get these errors,
Code:
Dave@PREFERRE-FA8B50 ~
$ cd /pspdev

Dave@PREFERRE-FA8B50 /pspdev
$ make
psp-gcc -I. -I/usr/psp/sdk/include -O2 -G0 -Wall   -c -o main.o main.c
main.c : In function 'main':
main.c(49) : error: syntax error before 'bool'
main.c(52) : error: 'rn0' undeclared (first use in this function)
main.c(52) : error: (Each undeclared identifier is reported only once
main.c(52) : error: for each function it appears in.)
main.c(56) : error: syntax error before ')' token
make: *** [main.o] Error 1

Dave@PREFERRE-FA8B50 /pspdev
$
int rand() { ... } is a function declaration.
remove that line and the braces and probably would be a good idea to have rn0 as
int rn0 = 0;

You could also probably remove the if statement for if pad.Buttons is pressed as it is handled with the next if statement

Code:
while (1)  {
          char buffer[200]
          int rn0 = 0;
          if(pad.Buttons & PSP_CTRL_CROSS) {
              rn0=rand()%10000;
          }
          if (rn0 != 0) {
            pspDebugScreenPrintf("Press 'X' to start.",);
          }
hartraft is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-07-2006, 06:20 AM   #14

AKA Homer
 
Moonchild's Avatar
 
Join Date: Jan 2006
Location: Sweden
Posts: 1,779
Trader Feedback: 0
Default

There is no such thing as a bool datatype in C, you either have to use BOOL (which really just is an int) or int.
__________________


Click Here if you want a Winamp Currently Playing Userbar like the one above.
Moonchild is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
coding or programming

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -8. The time now is 12:13 AM.



Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY
Copyright © 2009, QJ.NET. All Rights Reserved.
Contact Us