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!

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; If you mean cut a sprite sheet up then yes, you can... You use the offsets to do it... Image ...

Reply
 
LinkBack Thread Tools
Old 05-30-2006, 03:01 PM   #271

words are stones in my <3
 
SG57's Avatar
 
My Mood: Lonely
Join Date: Jul 2005
Real First Name: Jordan
Location: Spokane
Just Played: LotRO
Posts: 4,971
Trader Feedback: 0
Default

If you mean cut a sprite sheet up then yes, you can...

You use the offsets to do it...

Image dimensions of 100x100. Cut it in 2...

use the offsets for the first image ( 0, 50 )

Im jsut guessing on the use of the offsets, but i do know you use them to cut a sprite sheet up...
__________________

...at what speed must I live.. to be able to see you again?...

Projects
SG57 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Best prices available for:
Price Range:
$13.00 - $25.00
at 10 Stores

Price Range:
$17.00 - $48.00
at 10 Stores

Old 05-30-2006, 04:31 PM   #272
 
ZereoX's Avatar
 
Join Date: Jan 2006
Posts: 871
Trader Feedback: 0
Default

Hi, I learn lua quit a wild ago but im more interested in C/C++ where can i start i mean which are the best tut to start whit.
__________________
Free Prizes at [url=http://www.prizerebel.com/index.php?r=189687]Prizerebel[/url] Join us!
I already got [b]11[/b] Gifts. Ask me for details or proof.
ZereoX is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 05-30-2006, 04:39 PM   #273

words are stones in my <3
 
SG57's Avatar
 
My Mood: Lonely
Join Date: Jul 2005
Real First Name: Jordan
Location: Spokane
Just Played: LotRO
Posts: 4,971
Trader Feedback: 0
Default

ok... go to www.psp-programming.com thats where all the actual developers chill now a days youll find tutorials to get you started, then examples and general help on how to code in C/C++... even LUA, this forum hasnt really any real hardcore LUA dev's that dont know about psp-programming.com ...

This forum is now more of a release thread...
SG57 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 05-31-2006, 05:47 AM   #274

Developer
 
SodR's Avatar
 
Join Date: Sep 2005
Location: Sweden
Posts: 941
Trader Feedback: 0
Default

Quote:
Originally Posted by SG57
If you mean cut a sprite sheet up then yes, you can...

You use the offsets to do it...

Image dimensions of 100x100. Cut it in 2...

use the offsets for the first image ( 0, 50 )

Im jsut guessing on the use of the offsets, but i do know you use them to cut a sprite sheet up...
Yes, of course you can do that. How stupid of me. Thanks anyway.

Last edited by SodR; 05-31-2006 at 10:54 AM..
SodR is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 05-31-2006, 06:22 AM   #275

words are stones in my <3
 
SG57's Avatar
 
My Mood: Lonely
Join Date: Jul 2005
Real First Name: Jordan
Location: Spokane
Just Played: LotRO
Posts: 4,971
Trader Feedback: 0
Default

Mental blocks are pretty common in programming i guess...
SG57 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-01-2006, 06:46 AM   #276

Developer
 
SodR's Avatar
 
Join Date: Sep 2005
Location: Sweden
Posts: 941
Trader Feedback: 0
Default

When I try to animate a screen the second picture in the animation is displayed below the first one instead of on it.

This is the animation code:
Code:
	char intro_buffer[200];
	Image* intro;
	sprintf(intro_buffer, "./Intro.png");
	intro = loadImage(intro_buffer);

	char white_buffer[200];
	Image* white;
	sprintf(white_buffer, "./white.png");
	white = loadImage(white_buffer);

	screenblit(0, 0, 480, 272, white, 0, 0);
	screenblit(0, 0, 248, 59, intro, 120, 120);
	flipScreen();
	sceKernelDelayThread(1000000);

	screenblit(0, 0, 480, 272, white, 0, 0);
	screenblit(0, 59, 248, 118, intro, 120, 120);
	flipScreen();
	sceKernelDelayThread(1000000);

	screenblit(0, 0, 480, 272, white, 0, 0);
	screenblit(0, 118, 248, 177, intro, 120, 120);
	flipScreen();
	sceKernelDelayThread(1000000);

	screenblit(0, 0, 480, 272, white, 0, 0);
	screenblit(0, 177, 248, 224, intro, 120, 120);
	flipScreen();
	sceKernelDelayThread(1000000);
This is the screenblit function. I borrowed it from FlashMod and added a function to it so you can choose where to display the image (this might be the problem?):
Code:
void screenblit(int posx, int posy, int sizex, int sizey, Image* imagevar, int dx, int dy) {
	int x = 0;
        int y = 0;
        sceDisplayWaitVblankStart();

	while (x < sizex) {
		while (y < sizey) {
			blitAlphaImageToScreen(posx ,posy ,sizex , sizey, imagevar, dx, dy);
			y += sizey;
		}
		x += sizex;
		y = 0;
	}
}
Thanks in advance.

btw. the sceKernelDelayThread() is just temporary used. I'm just using it with my testings.
SodR is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-01-2006, 07:18 AM   #277

words are stones in my <3
 
SG57's Avatar
 
My Mood: Lonely
Join Date: Jul 2005
Real First Name: Jordan
Location: Spokane
Just Played: LotRO
Posts: 4,971
Trader Feedback: 0
Default

1. Put your images into an array for animation.
2. Dont flip the screen/draw buffer more then once (when animating)
3. Try this for a crappyly timed timer, and i havent tested it, its raw code i havent tested:
Code:
Image* animation[2];
animation[0] = loadImage("./Intro.png");
animation[1] = loadImage("./white.png");
 
actualImage = animation[0];
 
int x = 0, fakeTimer = 0;
 
while(1) {
	  screenblit(all that jazz here, animation[x], all that jazz here);
	  if (fakeTimer > 500 && fakeTimer<1000) x=1;
	  else {
		  x=0;
	  }
	  if (fakeTimer > 1000) { fakeTimer = 0;
}
Try that or soimething allong the lines... oh and there blitting lower because you put eah image's Y co-ordinate higher then the other one, thus meanig it slower on the screen since the Y value it upside down.
SG57 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-01-2006, 07:39 AM   #278

Developer
 
SodR's Avatar
 
Join Date: Sep 2005
Location: Sweden
Posts: 941
Trader Feedback: 0
Default

Thanks for the good example. But is there a way to do that with one "master" image ( that contains several sprites ) and ripping seperate sprites out of it??

Last edited by SodR; 06-01-2006 at 11:32 AM..
SodR is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-02-2006, 05:21 AM   #279

Developer
 
kozine's Avatar
 
Join Date: Mar 2006
Location: Isle of Wight
Posts: 491
Trader Feedback: 0
Default

Ok this sounds dumb but, is it:

Code:
pspWaitVblankStart();
??
I cant remember what it was lol.
__________________


PM me for a sig like this!

http://dspspforums.com/forums/index.php SIGN UP NOW!
kozine is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-02-2006, 05:29 AM   #280

Developer
 
SodR's Avatar
 
Join Date: Sep 2005
Location: Sweden
Posts: 941
Trader Feedback: 0
Default

Quote:
Originally Posted by kozine
Ok this sounds dumb but, is it:

Code:
pspWaitVblankStart();
??
I cant remember what it was lol.
It's
Code:
 sceDisplayWaitVblankStart();
SodR is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-02-2006, 05:30 AM   #281

Developer
 
kozine's Avatar
 
Join Date: Mar 2006
Location: Isle of Wight
Posts: 491
Trader Feedback: 0
Default

ok thankyou
kozine is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-02-2006, 05:31 AM   #282

Developer
 
SodR's Avatar
 
Join Date: Sep 2005
Location: Sweden
Posts: 941
Trader Feedback: 0
Default

Quote:
Originally Posted by kozine
ok thankyou
No problem. This thread is about helping, right?
SodR is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-02-2006, 05:40 AM   #283

Developer
 
kozine's Avatar
 
Join Date: Mar 2006
Location: Isle of Wight
Posts: 491
Trader Feedback: 0
Default

Code:
sceDisplayWaitVblankStart();
is it in mili seconds? If so, how many mili seconds to a second?

(Yes I know im dumb )
kozine is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-02-2006, 06:17 AM   #284

Developer
 
SodR's Avatar
 
Join Date: Sep 2005
Location: Sweden
Posts: 941
Trader Feedback: 0
Default

Quote:
Originally Posted by kozine
Code:
sceDisplayWaitVblankStart();
is it in mili seconds? If so, how many mili seconds to a second?

(Yes I know im dumb )
1000mili secs = 1sec.

Last edited by SodR; 06-02-2006 at 06:41 AM..
SodR is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-02-2006, 06:30 AM   #285
QJ Gamer Platinum
 
FreePlay's Avatar
 
Join Date: Dec 2005
Location: h0000000rj
Posts: 12,858
Trader Feedback: 0
Default

Quote:
Originally Posted by SodR
1000000mili secs = 1sec.
Um, no. 1000ms = 1s. mili = thousandth.
__________________
[I fail @ life]
FreePlay is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-02-2006, 06:41 AM   #286

Developer
 
SodR's Avatar
 
Join Date: Sep 2005
Location: Sweden
Posts: 941
Trader Feedback: 0
Default

Quote:
Originally Posted by FreePlay
Um, no. 1000ms = 1s. mili = thousandth.
Yes, my mistake. What I said was in micro secs.

Now it's edited =)
SodR is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-02-2006, 10:57 AM   #287

Developer
 
SodR's Avatar
 
Join Date: Sep 2005
Location: Sweden
Posts: 941
Trader Feedback: 0
Default

Does anyone have any tips of speeding up your program except changeing the cpus clock frequency?? (It mainly goes slow because of that it have many big images blited to the screen).

Last edited by SodR; 06-03-2006 at 02:22 AM..
SodR is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-03-2006, 12:57 PM   #288

Developer
 
kozine's Avatar
 
Join Date: Mar 2006
Location: Isle of Wight
Posts: 491
Trader Feedback: 0
Default

Ok guys im in need of help. Im trying to compile my program and it says:

main.c:391: error: syntax error at end of input

Line 391 is the very last line. Here is the last 4 lines (as I dont want people to see my code)

Code:
	// Exit Program

	while (1) {
		sceCtrlReadBufferPositive(&pad, 1);
		if (pad.Buttons & PSP_CTRL_CROSS) {

		      MP3_Stop();
		      MP3_FreeTune();
			sceKernelExitGame();
			break;
				}
			}

	return 0;

}
kozine is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-03-2006, 03:34 PM   #289

words are stones in my <3
 
SG57's Avatar
 
My Mood: Lonely
Join Date: Jul 2005
Real First Name: Jordan
Location: Spokane
Just Played: LotRO
Posts: 4,971
Trader Feedback: 0
Default

kozine - Its not necessarly your last lines that is making the error... the Complier here is complaining you have left a '{' bracket open, or added an extra '}' somewhere, my advice is to get a good code editing software (UltaEdit or Dev-C++) and it will highlight the backets start and finish ones, that way you can find the problem... Hope this helps.
SG57 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-04-2006, 02:44 AM   #290

Developer
 
kozine's Avatar
 
Join Date: Mar 2006
Location: Isle of Wight
Posts: 491
Trader Feedback: 0
Default

Thanks I got that sorted out and some other errors and it compiles now Thankyou SG57!
kozine is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-04-2006, 02:51 AM   #291

words are stones in my <3
 
SG57's Avatar
 
My Mood: Lonely
Join Date: Jul 2005
Real First Name: Jordan
Location: Spokane
Just Played: LotRO
Posts: 4,971
Trader Feedback: 0
Default



Thats what this thread is for.

Quote:
Originally Posted by SodR
Does anyone have any tips of speeding up your program except changeing the cpus clock frequency?? (It mainly goes slow because of that it have many big images blited to the screen).
yes, i have some...

1. Use external globals to help not make a brand new C source file just to have the same variable in 2 files
2. Use static variables instead of configuration files, that way theres no need to read/write from the mem stick for an always changing/same starting position variable...

Last edited by SG57; 06-04-2006 at 02:55 AM..
SG57 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-05-2006, 11:55 AM   #292

Developer
 
SodR's Avatar
 
Join Date: Sep 2005
Location: Sweden
Posts: 941
Trader Feedback: 0
Default

How do you use ascii with flib??

eg.
Code:
 text_to_screen("  %s\n", dirEntry->d_name, 350, 50);
doesn't work =S. Samstag told me that ascii was supported in flib. I get the "to many arguments to function" error...
SodR is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-05-2006, 03:01 PM   #293

words are stones in my <3
 
SG57's Avatar
 
My Mood: Lonely
Join Date: Jul 2005
Real First Name: Jordan
Location: Spokane
Just Played: LotRO
Posts: 4,971
Trader Feedback: 0
Default

..SodR, flib is for displaying True Type Fonts (TTF), no?

The prototype for the text_to_screen doesnt support optional parameters, there for you must feed the diretory names and the '\n' character into na buffer before printing:
Code:
char buffer[255];
struct dirent *dirEntry;
sprintf(buffer, " %s\n", dirEntry->d_name);
text_to_screen(buffer, 350, 50);]
hope that helps...

Oh and if your going to be changing directories, make sure you 'sprintf' again, orelse the 'd_name' / file list, wont be updated to display the n ewe files in the new folder...
SG57 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-05-2006, 08:42 PM   #294

Developer
 
Join Date: Oct 2005
Posts: 408
Trader Feedback: 0
Default

Quote:
Originally Posted by SodR
How do you use ascii with flib??

eg.
Code:
 text_to_screen("  %s\n", dirEntry->d_name, 350, 50);
doesn't work =S. Samstag told me that ascii was supported in flib. I get the "to many arguments to function" error...
You still seem to be confused about ascii. Your example shows printf escape codes, not ascii.

Code:
text_to_screen(dirEntry->d_name, 350, 50);
This is all you need to do in this case.
Samstag is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-05-2006, 08:47 PM   #295

words are stones in my <3
 
SG57's Avatar
 
My Mood: Lonely
Join Date: Jul 2005
Real First Name: Jordan
Location: Spokane
Just Played: LotRO
Posts: 4,971
Trader Feedback: 0
Default

Samstag - no, not neccesarly, that will print out the filenames, but no enter character, thus making it all one line...

(Unless the structure itself has a built in \n but i have tried it wihtout and it doesnt...)
SG57 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-05-2006, 08:53 PM   #296

Developer
 
Join Date: Oct 2005
Posts: 408
Trader Feedback: 0
Default

Quote:
Originally Posted by SG57
Samstag - no, not neccesarly, that will print out the filenames, but no enter character, thus making it all one line...

(Unless the structure itself has a built in \n but i have tried it wihtout and it doesnt...)
The variable dirEntry->d_name is a single filename, not a list of names.

If you send \n to flib, you'll get a backslash and an "n".
Samstag is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-05-2006, 09:08 PM   #297

words are stones in my <3
 
SG57's Avatar
 
My Mood: Lonely
Join Date: Jul 2005
Real First Name: Jordan
Location: Spokane
Just Played: LotRO
Posts: 4,971
Trader Feedback: 0
Default

Well i was assuming he was displaying the entire list of the filenames in the directory via a 'for' loop... meaning each time the loop repeated, it print the next filename, one line below...
SG57 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-06-2006, 02:44 AM   #298

Developer
 
SodR's Avatar
 
Join Date: Sep 2005
Location: Sweden
Posts: 941
Trader Feedback: 0
Default

Quote:
Originally Posted by Samstag
You still seem to be confused about ascii. Your example shows printf escape codes, not ascii.

Code:
text_to_screen(dirEntry->d_name, 350, 50);
This is all you need to do in this case.
I have never acctually used those kind of stuff very much but in my program I needed to use those functions. Thanks for informing me what it's called anyway.

Quote:
Originally Posted by Samstag
If you send \n to flib, you'll get a backslash and an "n".
Then what do you use for newline??
SodR is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-06-2006, 03:26 AM   #299

Developer
 
Join Date: Oct 2005
Posts: 408
Trader Feedback: 0
Default

Quote:
Originally Posted by SodR
Then what do you use for newline??
Change the Y value when you send the next line. You start with a Y value of 50 in your example. If you're using a 14 point font you could probably add 16 for each new line like this:
Code:
int y = 50;

for(i = 0; i < NUMBER_OF_LINES; i++)
{
        text_to_screen(line[i], 350, y);
        y += 16;
}
I'll probably add simple support for newlines in a later version.
Samstag is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-06-2006, 04:04 AM   #300

Developer
 
SodR's Avatar
 
Join Date: Sep 2005
Location: Sweden
Posts: 941
Trader Feedback: 0
Default

Quote:
Originally Posted by Samstag
Change the Y value when you send the next line. You start with a Y value of 50 in your example. If you're using a 14 point font you could probably add 16 for each new line like this:
Code:
int y = 50;

for(i = 0; i < NUMBER_OF_LINES; i++)
{
        text_to_screen(line[i], 350, y);
        y += 16;
}
I'll probably add simple support for newlines in a later version.
When I do like this I get a "makes pointer from integer without a cast" error. I can't figure out why. Do you know what to do to fix this?

btw. I assume that "i" is an integer with a value of 0 ( int i = 0; )
SodR is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
c or c , c++ , c/c++ , code , coding , c_language , programming , psp , psp programming , thread

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 07:32 PM.



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