| View previous topic :: View next topic |
| Author |
Message |
Josh1billion

Joined: 12 Jul 2005 Posts: 32 Location: Wisconsin, USA
|
Posted: Sat Jun 10, 2006 4:48 am Post subject: |
|
|
Nice library, first of all.
I have some problems that you might be able to help me with. First of all, I'm using C++, and no, this isn't about the bool thing (I already fixed that by deleting the "typedef short bool" line and replacing "bool" with "short" throughout the rest of that file).
Note that various examples from the site (such as the sprite example) DO compile and link without any problems.
I have a few different C++ source files (.cpp), and I include <oslib/oslib.h> into all three of them. But, this causes errors in the linker (after compiling), saying that it's trying to redefine stuff like "osl_intKeys" and "osl_powerCallBack." Removing the #include <oslib/oslib.h> line from two of the three C++ source files fixes the problem... but, of course, that's not a solution.
Here are the errors, I'm using the new Win32 dev environment that came out today (see PSP Updates).
| Quote: | mario.o:(.bss+0x0): multiple definition of `osl_intKeys'
main.o:(.bss+0x30): first defined here
mario.o:(.sbss+0x0): multiple definition of `osl_keys'
main.o:(.sbss+0x4): first defined here
mario.o:(.sbss+0x4): multiple definition of `osl_powerCallback'
main.o:(.sbss+0x8): first defined here
world.o:(.bss+0x8): multiple definition of `osl_intKeys'
main.o:(.bss+0x30): first defined here
world.o:(.sbss+0x0): multiple definition of `osl_keys'
main.o:(.sbss+0x4): first defined here
world.o:(.sbss+0x4): multiple definition of `osl_powerCallback'
main.o:(.sbss+0x8): first defined here
/cygdrive/c/pspdev/bin/../lib/gcc/psp/4.0.2/../../../../psp/lib/crt0.o: In funct
ion `_main':
/home/loser/newtoolchain/pspsdk/src/startup/crt0.c:86: undefined reference to `m
ain'
collect2: ld returned 1 exit status
make: *** [test.elf] Error 1 |
_________________ Josh1billion - PHP, C++, PSP programmer. |
|
| Back to top |
|
 |
dot_blank

Joined: 28 Sep 2005 Posts: 498 Location: Brasil
|
Posted: Sat Jun 10, 2006 6:26 am Post subject: |
|
|
you cannot define multiple times ...this is not just OS lib problem
just have one file where you keep the defines ...ex. defines.h
and have other source include that one and it should be fine _________________ 10011011 00101010 11010111 10001001 10111010 |
|
| Back to top |
|
 |
Josh1billion

Joined: 12 Jul 2005 Posts: 32 Location: Wisconsin, USA
|
Posted: Sat Jun 10, 2006 9:13 am Post subject: |
|
|
I didn't define those, they're inside of oslib/oslib.h
edit: It seems this is merely a C++ compatibility issue. I'm looking forward to the next release.. :) _________________ Josh1billion - PHP, C++, PSP programmer. |
|
| Back to top |
|
 |
Zettablade
Joined: 05 May 2006 Posts: 71
|
Posted: Sun Jun 18, 2006 6:44 pm Post subject: |
|
|
hey, love the lib, nothing better for 2d games, which people should make anyways. But I've run into a problem. I can't get diagonal control checking with the dpad or the anolog nub.
| Code: | int a;
oslReadKeys();
//joystick
for (a=60;a<=120;a+=60)
{
if (osl_keys->analogX > a) {
//Do something
} else if (osl_keys->analogY > a) {
//Do something
} else if (osl_keys->analogX < -a) {
//Do something
} else if (osl_keys->analogY < -a) {
//Do something
} else {
//Do something when the stick isn't moved
}
} |
But when I add something like
| Code: | if (osl_keys->analogX > a && osl_keys->analogY > a) {
//do something when analog
} |
it won't work. help please? |
|
| Back to top |
|
 |
johnsto
Joined: 18 Jan 2006 Posts: 30
|
Posted: Sun Jun 18, 2006 6:48 pm Post subject: |
|
|
The problem is you're treating X and Y as if they're the same thing... try this instead:
| Code: | int a;
oslReadKeys();
//joystick
for (a=60;a<=120;a+=60)
{
if (osl_keys->analogX > a) {
//Do something
} else if (osl_keys->analogX < -a) {
//Do something
} else {
// stick not moved sideways
}
if (osl_keys->analogY > a) {
//Do something
} else if (osl_keys->analogY < -a) {
//Do something
} else {
// stick not moved upwards or downwards
}
} |
|
|
| Back to top |
|
 |
Zettablade
Joined: 05 May 2006 Posts: 71
|
Posted: Sun Jun 18, 2006 6:54 pm Post subject: |
|
|
| Ok, now how do I add the diagonal checks? |
|
| Back to top |
|
 |
johnsto
Joined: 18 Jan 2006 Posts: 30
|
Posted: Sun Jun 18, 2006 6:56 pm Post subject: |
|
|
| Zettablade wrote: | | really. it doesn't look like that would solve it. But what ever. i'll try it. |
No it won't solve it. It's just to point you in the right direction. I don't know enough about what you're trying to do to solve it. |
|
| Back to top |
|
 |
Zettablade
Joined: 05 May 2006 Posts: 71
|
Posted: Sun Jun 18, 2006 6:58 pm Post subject: |
|
|
| I've pretty much got a little guy running around one screen, and I need him to run diagonally. |
|
| Back to top |
|
 |
johnsto
Joined: 18 Jan 2006 Posts: 30
|
Posted: Sun Jun 18, 2006 7:04 pm Post subject: |
|
|
| Zettablade wrote: | | I've pretty much got a little guy running around one screen, and I need him to run diagonally. |
Ok, in that case the code I posted should definitely help you.
The problem was that your code was basically only checking if the joystick had moved up OR down OR left OR right. It wouldn't detect if the joystick had moved up AND left for example, because all the checks were in the same 'if' block, and as soon as one of those was true, it stopped checking the rest. |
|
| Back to top |
|
 |
Zettablade
Joined: 05 May 2006 Posts: 71
|
Posted: Sun Jun 18, 2006 7:08 pm Post subject: ok |
|
|
so, now i just add all the diagonal checks in a sperate if block and it should work? Same with the dpad right?
Wait, I just realized something. If it checked for diagonal at the beginning of an if block with everything in it, shouldn't it work? |
|
| Back to top |
|
 |
johnsto
Joined: 18 Jan 2006 Posts: 30
|
Posted: Sun Jun 18, 2006 7:12 pm Post subject: Re: ok |
|
|
| Zettablade wrote: | | so, now i just add all the diagonal checks in a sperate if block and it should work? Same with the dpad right? |
Well, I spose that's one way of doing it.
The code I showed you basically did two things - first it checks if the joystick has moved sideways. Then it checks if it has moved vertically.
If in the sideways bit you put your "move character left/right" code, and in the vertical bit you put in your "move character up/down" code, then that's all you need. If the joystick is moved sideways and vertically, both parts of your code will execute (which will move your character left/right AND up/down) and the character will move diagonally. |
|
| Back to top |
|
 |
Zettablade
Joined: 05 May 2006 Posts: 71
|
Posted: Sun Jun 18, 2006 7:14 pm Post subject: Re: ok |
|
|
| johnsto wrote: | | Zettablade wrote: | | so, now i just add all the diagonal checks in a sperate if block and it should work? Same with the dpad right? |
Well, I spose that's one way of doing it.
The code I showed you basically did two things - first it checks if the joystick has moved sideways. Then it checks if it has moved vertically.
If in the sideways bit you put your "move character left/right" code, and in the vertical bit you put in your "move character up/down" code, then that's all you need. If the joystick is moved sideways and vertically, both parts of your code will execute (which will move your character left/right AND up/down) and the character will move diagonally. |
But it's a little different when you need to show visuals of them running diagonally. As I said before, if it checked for diagonal at the beginning of an if block with everything in it, shouldn't it work? |
|
| Back to top |
|
 |
johnsto
Joined: 18 Jan 2006 Posts: 30
|
Posted: Sun Jun 18, 2006 7:24 pm Post subject: Re: ok |
|
|
| Zettablade wrote: |
But it's a little different when you need to show visuals of them running diagonally. As I said before, if it checked for diagonal at the beginning of an if block with everything in it, shouldn't it work? |
Yep, it is and yes that should work if you do the if-statements right. It's pretty untidy (imo) but it should work.
| Code: |
if (osl_keys->analogX > a && osl_keys->analogY > a) {
// up-right
} else if (osl_keys->analogX < -a && osl_keys->analogY > a) {
// up-left
} else if (osl_keys->analogX > a && osl_keys->analogY < -a) {
// down-right
} else if (osl_keys->analogX < -a && osl_keys->analogY < -a) {
// down-left
} else if (osl_keys->analogX > a) {
// right
} else if (osl_keys->analogY > a) {
// up
} else if (osl_keys->analogX < -a) {
// left
} else if (osl_keys->analogY < -a) {
// down
} else {
//nothing
}
|
I can't remember properly, but I think full X/Y on the analog stick is not equivalent to full X or full Y (because it's circular), so you might want to reduce the granularity of your if-loop to something much less. (i.e. the value in 'a' might be too large for the diagonal value checks) |
|
| Back to top |
|
 |
Zettablade
Joined: 05 May 2006 Posts: 71
|
Posted: Sun Jun 18, 2006 7:30 pm Post subject: |
|
|
That worked, thanks.
Now I need to swizzled an image. how do i do that? |
|
| Back to top |
|
 |
Zettablade
Joined: 05 May 2006 Posts: 71
|
Posted: Mon Jun 19, 2006 4:52 pm Post subject: |
|
|
| meh, i changed my last post, just thought i'de bump it up for attention. |
|
| Back to top |
|
 |
Brunni
Joined: 08 Oct 2005 Posts: 186
|
Posted: Mon Jun 19, 2006 6:04 pm Post subject: |
|
|
You can use the following: oslCreateSwizzledImage, oslSwizzleImage (currently works only if imgSrc != imgDst, so you should use the other).
Sorry for not being very active, I just finished my exams, and I'm trying to fix a weird bug that provokes random crashes. I've reread my code 10 times and found nothing bad, and I'm not even sure if it doesn't come from my application which uses OSLib (but shouldn't, it's very simple), or even from the compiler itself.
So it's why I'm asking you: has anyone had random crashes (works for a build, crashes the other, or gets graphic corruption, flickering, etc.) when using OSLib? I really need your experience (even if it worked properly all the time).
Also, if anyone wants to help me fixing this issue, please PM me or post here, it would be very kind of you ;)
Thanks in advance _________________ Sorry for my bad english
Oldschool library for PSP - PC version released |
|
| Back to top |
|
 |
Zettablade
Joined: 05 May 2006 Posts: 71
|
Posted: Mon Jun 19, 2006 6:10 pm Post subject: |
|
|
| Brunni wrote: | You can use the following: oslCreateSwizzledImage, oslSwizzleImage (currently works only if imgSrc != imgDst, so you should use the other).
Sorry for not being very active, I just finished my exams, and I'm trying to fix a weird bug that provokes random crashes. I've reread my code 10 times and found nothing bad, and I'm not even sure if it doesn't come from my application which uses OSLib (but shouldn't, it's very simple), or even from the compiler itself.
So it's why I'm asking you: has anyone had random crashes (works for a build, crashes the other, or gets graphic corruption, flickering, etc.) when using OSLib? I really need your experience (even if it worked properly all the time).
Also, if anyone wants to help me fixing this issue, please PM me or post here, it would be very kind of you ;)
Thanks in advance |
It's nice to meet you. I love your lib! It's the best in the world.
Now that i've said that, can you give me a quick example of using oslCreateSwizzled Image.
and one last thing. I can totally relate to having flickering/disappearing images. it happens all the time. I've got it fixed right now, but if you want, i can tell you what's happened and what i did to fix it. |
|
| Back to top |
|
 |
Zettablade
Joined: 05 May 2006 Posts: 71
|
Posted: Tue Jun 20, 2006 3:56 pm Post subject: |
|
|
| ok, finally got the image swizzled. But i heard that you can bypass image size restrictions by swizzling. How do i do that? |
|
| Back to top |
|
 |
Brunni
Joined: 08 Oct 2005 Posts: 186
|
Posted: Tue Jun 20, 2006 5:24 pm Post subject: |
|
|
Thank you. I didn't even know that the image size could be bypassed by swizzling (and I seriously doubt from it), so I can't help you, sorry. Basically, the advantage of swizzling is the speed (but it's only for fixed images).
And can you explain please what was your flickering problem? _________________ Sorry for my bad english
Oldschool library for PSP - PC version released |
|
| Back to top |
|
 |
Zettablade
Joined: 05 May 2006 Posts: 71
|
Posted: Tue Jun 20, 2006 5:31 pm Post subject: |
|
|
| Brunni wrote: | Thank you. I didn't even know that the image size could be bypassed by swizzling (and I seriously doubt from it), so I can't help you, sorry. Basically, the advantage of swizzling is the speed (but it's only for fixed images).
And can you explain please what was your flickering problem? |
For some reason it was flickering and such. So after a lot of debugging and such I figured it out.
| Code: | int main(int argc, char* argv[])
{
//Initialization
oslInit(0); //The lib
oslInitGfx(OSL_PF_8888, 1); //Gfx
oslInitConsole(); //Text
//Main loop
while (!osl_quit)
{
oslSwapBuffers();
oslStartDrawing();
oslSetDrawBuffer(OSL_SECONDARY_BUFFER);
//diplay the images and such
oslEndDrawing();
oslSyncFrame();
}
oslEndGfx();
oslWaitVSync();
oslQuit();
return 0;
} |
Hope this helps. Anything to improve this lib. If you wanna see the full code, I can pm it to you.
Also, Does anyone know how to load an image saved as a .c file and blit it to the screen? I'de really like to know. |
|
| Back to top |
|
 |
Brunni
Joined: 08 Oct 2005 Posts: 186
|
Posted: Tue Jun 20, 2006 10:22 pm Post subject: |
|
|
Image size restriction is an hardware PSP limit. Loading from a file or data won't change anything ;-)
Else, do you know what this does?
oslSetDrawBuffer(OSL_SECONDARY_BUFFER);
It sets up to draw on the currently visible screen buffer, making double-buffering useless, it's why you got flickering ;-)
I was talking about random crashes ^^
I'm still testing to find this problem, but that's not easy :-(
Source will be released soon, I have to finalize this newer version (which will have C++ support, Windows version, optimizations and some new things) and clean it, but if you really need it, you can still ask the temporary version to me ^^
You can also ask for new features, but keep in mind that OSLib was designed to be simple and extensible, but especially fast and lightweight. _________________ Sorry for my bad english
Oldschool library for PSP - PC version released |
|
| Back to top |
|
 |
Zettablade
Joined: 05 May 2006 Posts: 71
|
Posted: Tue Jun 20, 2006 10:31 pm Post subject: |
|
|
| Brunni wrote: | Image size restriction is an hardware PSP limit. Loading from a file or data won't change anything ;-)
Else, do you know what this does?
oslSetDrawBuffer(OSL_SECONDARY_BUFFER);
It sets up to draw on the currently visible screen buffer, making double-buffering useless, it's why you got flickering ;-)
I was talking about random crashes ^^
I'm still testing to find this problem, but that's not easy :-(
Source will be released soon, I have to finalize this newer version (which will have C++ support, Windows version, optimizations and some new things) and clean it, but if you really need it, you can still ask the temporary version to me ^^
You can also ask for new features, but keep in mind that OSLib was designed to be simple and extensible, but especially fast and lightweight. |
Ok, now it makes sense.
Anyways I've decided to just load it in seperate images instead of a sprite sheet. :P Take that file restriction...:'(
So I loaded it as an array. I have a little guy that's supposed to run around. problem is, when the the image number on the array changes, and changes the the image, the x/y cords don't same the same for all the images. so, how do I make a global y/x cord that works for all the images in the array.
Last edited by Zettablade on Wed Jun 21, 2006 4:48 pm; edited 2 times in total |
|
| Back to top |
|
 |
Zettablade
Joined: 05 May 2006 Posts: 71
|
Posted: Wed Jun 21, 2006 11:55 am Post subject: |
|
|
wow, my last post was a big giant garble of un readable content. lol
Well, I've changed it. mods may delete this if they see fit. |
|
| Back to top |
|
 |
Brunni
Joined: 08 Oct 2005 Posts: 186
|
Posted: Wed Jun 21, 2006 5:12 pm Post subject: |
|
|
I don't really understand your question, but oslDrawImageXY (passing your global x/y pos each time) might be the answer :p _________________ Sorry for my bad english
Oldschool library for PSP - PC version released |
|
| Back to top |
|
 |
Zettablade
Joined: 05 May 2006 Posts: 71
|
Posted: Wed Jun 21, 2006 5:14 pm Post subject: |
|
|
| Brunni wrote: | | I don't really understand your question, but oslDrawImageXY (passing your global x/y pos each time) might be the answer :p |
lol either way, that probably is the answer.
I'll try that in a second.
Edit:: yeah it worked. The images all move together now. lol. I'm loving oslib more and more each and every day.
Edit:: I added some sound to the program. I'm using the .bgm file from your maps & sound sample program. It loads and plays the bgm file, but music slow, scratchy, and unreconizable. what's does this mean?
Some thing I've found is that the audoi plays correctly, but only when assigned to play after a button press. I dunno why? Brunni? |
|
| Back to top |
|
 |
Zettablade
Joined: 05 May 2006 Posts: 71
|
Posted: Thu Jun 22, 2006 4:15 pm Post subject: |
|
|
| Bumped! |
|
| Back to top |
|
 |
jsharrad
Joined: 20 Oct 2005 Posts: 102
|
Posted: Sun Jun 25, 2006 3:01 pm Post subject: |
|
|
| Is it possible to use this with wifi? I am switching to a user thread after the wifi is setup but my psp locks up when I blit an image (loading the image works fine) |
|
| Back to top |
|
 |
Zettablade
Joined: 05 May 2006 Posts: 71
|
Posted: Sun Jun 25, 2006 3:16 pm Post subject: |
|
|
| jsharrad wrote: | | Is it possible to use this with wifi? I am switching to a user thread after the wifi is setup but my psp locks up when I blit an image (loading the image works fine) |
Hmm...I would assume it is. You can use the pspsdk in conjunction with this so you should be able to. if not, then I'm screwed, because my game will neverhave online play, which I plan to base it on. :p |
|
| Back to top |
|
 |
Brunni
Joined: 08 Oct 2005 Posts: 186
|
Posted: Sun Jun 25, 2006 7:05 pm Post subject: |
|
|
Update!!!
*Should* fix the following:
- Conditional: 2.01+ support
- No more random crashes
- C++ support
It also adds some undocumented features, wait for the definitive version until they are ;-)
I've still not added the source, I'll do it for the definitive release.
Please report me whether it works on 2.01/2.5/2.6, or if you got any problem with it. Download. _________________ Sorry for my bad english
Oldschool library for PSP - PC version released
Last edited by Brunni on Mon Jun 26, 2006 6:43 pm; edited 1 time in total |
|
| Back to top |
|
 |
Zettablade
Joined: 05 May 2006 Posts: 71
|
Posted: Mon Jun 26, 2006 5:51 pm Post subject: |
|
|
| sweet! hope you get the english docs finished soon. i have a bug to report though. on a 2.6, it crashes on the exit. |
|
| Back to top |
|
 |
|