![]() |
| Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact |
| ||||||
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; im not making a simple imaging program i just left the name as it is because it doesnt matter right ...
![]() |
|
|
LinkBack | Thread Tools |
|
|
#31 |
![]() |
im not making a simple imaging program i just left the name as it is because it doesnt matter right now i was just testing my code to see if everythin i was coding was already workin
and cud u explain wat wrote u got me confused |
|
|
|
|
|
#32 |
![]() |
thanks yel, every tut is comprehensicve and helpful. I am having one problem insignificant of a thread, and i was hoping that you guys could help me out. I have tried everything (even looking through the OG Keringham book) to find things on time. I am well aware of all the time functions and all that it can give me, but alas, it only goes down to seconds. is there any way to tell the psp to do something, say, every 1/4 of a second without measuring processor speeds and doing humgous math?
much thanks. posted in right thread, sorry. |
|
|
|
|
|
#33 | |
|
Quote:
while (1) { spawn new thread; // i.e. your work sleep(250); } Basically main loop just waits, then spawns new thread todo the work... but this solution assumes that the threads that is spawned would either not share resources with the next thread created (can od done though), or takes less than the sleep period to complete it's task. |
||
|
|
|
|
|
#35 |
![]() Mushroom Man
|
The PSPs own API also has a sleep function which can be measured in nano instead of mili. sceKernelDelayThread(2500 00); = delay for 1/4 of a second.
__________________
[URL=http://www.othala.co.uk]Othala[/URL] [B]o[/B] [URL=http://www.entheogendefencefund.org.uk/]Save the shroom![/URL] [CENTER][URL=http://www.othala.co.uk/travellerBlog][IMG]http://www.othala.co.uk/graphics/travBanner.png[/IMG][/URL][/CENTER] |
|
|
|
|
|
#36 |
![]() ![]() ...in a dream...
|
wait so say i wanted a to dsiplay an image for say 5 seconds, what would i do? i cant seem to find a way, the closes ive gotten is this...
Code:
blitAlphaImageToScren(0, 0, width, height, variable*, posX, posY);
for(i=0; i<15; i++) {
sceDisplayWaitVblankStart();
}
__________________
...you'll never know what it's like... spending your whole life in a dream...
Launch a Kitten out of a Cannon and win real cash! Checkout my newly updated site for all my projects (Kitten Cannon, BOXHEAD, Light Cycle 3D) |
|
|
|
|
|
#37 | ||
![]() ![]() Developer
|
Quote:
The reason for this is so that it doesn't perform a check to see if the statement is true when looping. Infinite loops doesn't need this. Maybe the compiler optimizes this, I don't know, but for max performance, I would do it this way: Code:
for( ; ; )
{
spawn new thread; // i.e. your work
sleep(250);
}
__________________
Quote:
|
||
|
|
|
|
|
#38 |
![]() ![]() ...in a dream...
|
ok, that kinda helps me, i dunno really, im working on a side scrolling backround, but i cant load an image with bigger width than 500, how can i do such a thing? may be if i blit the image and if this object goes on this certain pixel line, then it blits the image 1 pixel to the right and blit the new backround under it to take up hte bladc space, anyone have a good example of a side scrolling backround? like the one in little fighter? except thats in lua, so maybe just something so if an image/something goes on a certain pixel, than itll scroll? i dunno just asking some random questions
__________________
...you'll never know what it's like... spending your whole life in a dream...
Launch a Kitten out of a Cannon and win real cash! Checkout my newly updated site for all my projects (Kitten Cannon, BOXHEAD, Light Cycle 3D) |
|
|
|
|
|
#39 |
![]() |
Does anyone know how I can do the equivalent of
Code:
firstpointball = malloc( sizeof(struct pointball) ); I understand some of the variables it's asking for, but not sure what I should have in there for partitionid and name... The snippet of code is creating a new node on a linked list, and because i'm using malloc I think it's affecting it's combatibility with 2.1+ Also, if Fanjita see's this thread, what limitations are there for programming 2.1+ or are they the same as 2.0 ?
__________________
PSN: Shatterdome |
|
|
|
|
|
#40 |
![]() ![]() ...in a dream...
|
i also wish to know tis fanjita, should more than the PSP_MODULE, Kernel Calls,etc. be removed?
__________________
...you'll never know what it's like... spending your whole life in a dream...
Launch a Kitten out of a Cannon and win real cash! Checkout my newly updated site for all my projects (Kitten Cannon, BOXHEAD, Light Cycle 3D) |
|
|
|
|
|
#41 |
![]() Mushroom Man
|
2.0+ proofing is also a subject I'm very interested in. It seems the calls mapped in the toolchain are very hit and miss when it comes to coding software that will work with Fanjitas loader. Trial and error is the only way I guess, bar delving into the toolchain to check out what is causing problems
.
__________________
[URL=http://www.othala.co.uk]Othala[/URL] [B]o[/B] [URL=http://www.entheogendefencefund.org.uk/]Save the shroom![/URL] [CENTER][URL=http://www.othala.co.uk/travellerBlog][IMG]http://www.othala.co.uk/graphics/travBanner.png[/IMG][/URL][/CENTER] |
|
|
|
|
|
#42 |
![]() |
Yeah, unfortunately all I have is a 1.5....
There is a thread on ps2dev.org on how to program for the 2.0, just not sure if it's the same for 2.1+... For 2.0 the biggest thing is not to call kernel access (But even one of my games which I was calling kernel acces too loaded once in awhile, but I was just passing the parameter, not actually doing anything with the kernel access) Then for stability he says to use scemempartitionalloc instead of the malloc that is in the new libc, but the sce function asks for a few extra parameters/variables then malloc, which just needs the size of the memory to set aside....ill let you know if I hear anything...
__________________
PSN: Shatterdome |
|
|
|
|
|
#43 |
![]() ![]() ...in a dream...
|
ok, hope u get an answer for us soon seeing as how i want to try to complie one of my demos for 2.0 support and see what happens, the inly thing im really doing is calling PSP_MODULE, ill remove it adn then itl work on 2.0 + right
__________________
...you'll never know what it's like... spending your whole life in a dream...
Launch a Kitten out of a Cannon and win real cash! Checkout my newly updated site for all my projects (Kitten Cannon, BOXHEAD, Light Cycle 3D) |
|
|
|
|
|
#45 |
![]() |
Depends how many different functions you are using, and in what categories.
If you've created 100 functions to handle gameplay, such as fighting, deteriming damage, level up...etc. It's usually a good idea not to clutter up your main.c, you create a fightfuncts.c with all your code in it, then a fightfuncts.h with your function prototypes, include it in your main.c. Then when you want to change something to do with fighting, you look through the fightfunct.c/h instead of trying to sort through a super huge main.c I've yet to make a big enough program to warrant that yet though :P Although you can do it with any # of functions just for good practice and to keep things neat...
__________________
PSN: Shatterdome |
|
|
|
|
|
#47 |
![]() ![]() ...in a dream...
|
ya i call that calling functions from other source files, i have like 5 other source files other than my main.c, 1 for credits, one for game, one for debug, one for options, and 1 for menu, and chingwyn, i think i found a good gravity, i got to talkto u somewhere about it to see what you think, AIM, msn, pm, or what
__________________
...you'll never know what it's like... spending your whole life in a dream...
Launch a Kitten out of a Cannon and win real cash! Checkout my newly updated site for all my projects (Kitten Cannon, BOXHEAD, Light Cycle 3D) |
|
|
|
|
|
#48 |
![]() ![]() ...in a dream...
|
ok, back with another problem needing an answer, i have a score (not really but for example use it), and say i wanted to print it to the screen, but it has a variable in it (%i), so far get it? Ok, i call printf("iasjdkfsjk %i", score); ok, now this works, except it just scrolls by really fast by the screen with this black bar under it, i want it to just stay where i put, but i nat no matter what, so i looked in graphics.h and found printtextimage or whatever and it works!, but it is behind the images before it a little bit and i cant use an integer call or anythng in it, anyone want to point in the right direction for printing text to the screen above multiple images, that can hold an integer argument? also, one more question, how do i get .mp3 music to stop and not play and not freeze and such if i go back and forth etween source files in a game?
__________________
...you'll never know what it's like... spending your whole life in a dream...
Launch a Kitten out of a Cannon and win real cash! Checkout my newly updated site for all my projects (Kitten Cannon, BOXHEAD, Light Cycle 3D) |
|
|
|
|
|
#50 |
![]() |
SG57, use...
Code:
char buffer[100]; (I use a large number to be safe) sprintf(buffer,"Score: %i",playerone.score); printTextScreen(300,10,buffer,brightred); Code:
Color brightred = RGB(200, 0, 0); Code:
Color brightblue = RGB( 0, 0,200); As far as making sure the score is on top of everything, just make sure it's the last thing drawn before you flipscreen(); MP3's...no clue, yet to learn me that...
__________________
PSN: Shatterdome Last edited by Shatterdome; 02-07-2006 at 03:19 PM.. |
|
|
|
|
|
#51 |
![]() ![]() ...in a dream...
|
no whats weird? i just did that and learned how to do that, but didnt try and i fixed the MP3 thing without ur help ( you were too slow), but as for that, ill try it out and then probably relase another of my demos just for laughs, you ahve to see this lol, your a cat dodging huge fireballs, but i cnat get collisio detection
any help? just use fireballx and firerebally as those co-ordinates and catx and caty for the cats, the dimensions of the fireblal is 60 x 60 and cat is 32 x 32 thanks!
__________________
...you'll never know what it's like... spending your whole life in a dream...
Launch a Kitten out of a Cannon and win real cash! Checkout my newly updated site for all my projects (Kitten Cannon, BOXHEAD, Light Cycle 3D) |
|
|
|
|
|
#52 |
![]() |
__________________
PSN: Shatterdome |
|
|
|
|
|
#53 |
![]() |
oh and i'll have to get you to learn me how to get mp3's running once I get to that point in my game...although I guess it would be something I should implement asap, make sure it doesn't effect anything else. What .h file do you use for that ?
__________________
PSN: Shatterdome |
|
|
|
|
|
#54 | |
![]() ![]() ...in a dream...
|
Quote:
1. svn co svn://svn.pspdev.org/psp/trunk/libmad cd libmad make manually install the include folder and .a file to its place 2. download mp3player.h and mp3player.c from that one thread a while back 3. Code:
#include <pspaudio.h>
#include <pspaudiolib.h>
#include "mp3player.h"
int main() {
pspAudioInit();
MP3_Init(1);
MP3_Load("yourmp3namehere.mp3");
while(1) {
do what ever you want and stuff
MP3_Play();
}
}
add -lpspaudio and -lpspaudiolib and -lmad to the libs line, and thas about it but if u wnat to stop the music, aminly so the psp doesnt freeze for whe going from the main gmae nad menuj and back, then go into the mp3player.h and add 'extern void MP3_FreeTune();' that other tut thing didnt have that so nothing ever worked when quiting! pretty bad tut if u ask me but it worked after i fixed my own
__________________
...you'll never know what it's like... spending your whole life in a dream...
Launch a Kitten out of a Cannon and win real cash! Checkout my newly updated site for all my projects (Kitten Cannon, BOXHEAD, Light Cycle 3D) |
|
|
|
|
|
|
#55 |
![]() |
Seems simple enough...guess this is only good for BG music though and not SFX...I'm a little wary on clocking up to 333 just to get music going as well...as right now i'm running my game at 11mhz and want to keep it as low as possible, just slowly clocking it up when I add something that slows it down...so I guess I should look into how to play wavs, or some other uncompressed sound file...
__________________
PSN: Shatterdome |
|
|
|
|
|
#56 |
![]() ![]() ...in a dream...
|
o, then get SDL and SDL_mixer and look thro the .h file of wav and walaa. thats what i did, its kinda confusing but it works
__________________
...you'll never know what it's like... spending your whole life in a dream...
Launch a Kitten out of a Cannon and win real cash! Checkout my newly updated site for all my projects (Kitten Cannon, BOXHEAD, Light Cycle 3D) |
|
|
|
|
|
#57 | |
![]() ![]() Developer
|
Also Shatterdome, if you want the Mp3 to stop after it has run once, put this into a loop somewhere in your code -
Code:
if (MP3_EndOfStream() == 1) MP3_Stop(); On the CPU side of things, 333 Mhz was just to be safe so that people could do pretty much whatever they wanted and not complain that the Mp3 playing made their app slow. I believe that libmad is quite reasonably efficient, and I know for certain it works at 222 Mhz. Give the lower speeds a try and if they work, all good. Your mileage may vary depending on bitrate etc however. SG57 - Quote:
Please however, if you did something to help improve the source code, send me a note and from it you'll help others. How will the tutorial improve if we hide behind a sort of closed source mentality? Anyway, thanks for working that problem through. Also, to note, Mp3_FreeTune is called on when using Mp3_Exit, so you don't really need to call on them seperately.
__________________
Developer of Airstrike |
|
|
|
|
|
|
#58 | |
![]() ![]() ...in a dream...
|
Quote:
ok, my question, is there anyway i could make like an options.txt as an options menu kinda? meaning itll erad it, then if ackround option is 1 then itll blit this backround, but if its 0, hten itll blit the other backround, get it?
__________________
...you'll never know what it's like... spending your whole life in a dream...
Launch a Kitten out of a Cannon and win real cash! Checkout my newly updated site for all my projects (Kitten Cannon, BOXHEAD, Light Cycle 3D) |
|
|
|
|
|
|
#59 |
![]() |
That's good to know, so feasibly you could play sound effects with it...but would that effect the bgmusic ? is it possible to load different mp3's onto different channels ? Then just have one for music and one for sound effects ?
Then it'd be a matter of finding a decent sounding but still low bitrate setting so that maybe the psp doesn't even have to be at 222.... I'm just thinking about it now...2 more days and I get a week off from school and i'm gonna hit my game hard...
__________________
PSN: Shatterdome |
|
|
|
|
|
#60 |
![]() ![]() ...in a dream...
|
ok, 2 more problems needing answers, 1st, when ever i try what u said shatterdome, it displays on the top of all my pictures fine, and the variable will show, as 0 to start, but it wont increase, even if i put X = score++;, probably menaing the text wont refresh thus meaning the variable wont increase, unless, its the variable its selfs problem because i put if score = 10, hen do menu(); which would take u to the main emnu and it wshould, but it doesntmeaning the int wont go up or move at all, i dunno ill work on it
2nd, i need help on animation arrays, meaning i ahve 3 images, how could i set them up in an array and blit 1 at a time infinintly making the image an animation? i knwo its possible but how? thanks...
__________________
...you'll never know what it's like... spending your whole life in a dream...
Launch a Kitten out of a Cannon and win real cash! Checkout my newly updated site for all my projects (Kitten Cannon, BOXHEAD, Light Cycle 3D) |
|
|
|
![]() |
| Tags |
| c or c , c++ , c/c++ , code , coding , c_language , programming , psp , psp programming , thread |
| Thread Tools | |
|
|