forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Control responce slow

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
wacco



Joined: 24 Aug 2005
Posts: 3

PostPosted: Mon Aug 29, 2005 2:34 am    Post subject: Control responce slow Reply with quote

Hi there,

I've recently started fiddling around with the pspsdk, and ran into a little trouble. When I'm combining code from the examples cube.c (gu/cube) and controller.c (controller/basic) the responce time of the input is extremely slow, or even none at all.
My source can be found here: http://www.jlpro.nl/wacco/cube.c
The main thing is the following line:
Quote:

cursor_vertices[1].x = ((float) pad.Lx - 123);


Since I thought that the above was a little extreme, I did a divide by 10 first. Since that didn't seem to work I ended up with the above. Now, if you try really hard the vertex might change, but don't expect to much of it. Most of the time, it doesn't move at all.
If you replace that line with the following:
Quote:

if(pad.Buttons != 0) {
if(pad.Buttons & PSP_CTRL_SQUARE) val2 = -2;
} else val2 = -1;
cursor_vertices[1].x = val2;

It does work, but extremely slow. Press the button, keep it pressed and wait... wait... wait... ah, there we go. Release it, wait... wait.. you get the idea.

Anybody has an idea what I'm doing wrong? The lights on the vertexes (comes from lights.c (gu/lights) btw) work fluently, and I'm kinda clueless.

Thanks :)
Back to top
View user's profile Send private message
rinco



Joined: 21 Jan 2005
Posts: 255
Location: Canberra, Australia

PostPosted: Mon Aug 29, 2005 7:45 am    Post subject: Reply with quote

Code:
cursor_vertices[1].x = ((float) pad.Lx - 123);


Try multiplying pad.Lx by a float, instead of casting.
Back to top
View user's profile Send private message
wacco



Joined: 24 Aug 2005
Posts: 3

PostPosted: Sun Sep 11, 2005 5:50 am    Post subject: Reply with quote

Solved it. Took a while, but that's mainly because I was busy doing other stuff. For completeness I explain what I did wrong (and the post above doesn't really make sence, nofi, but I hope you realised that yourself).

The main problem was that nobody told or gave a demo of how he/she did the trick in hardware (or at least with pspsdk functions) and the demo's which did do multiple objects parsed all the translations in software. I tried to change the vertices straight away which was stupid (I knew that) because I tried to avoid matrix calculations completely. Apparantly, your psp doesn't like that. :)

The trick is that sceGumTranslate() translates all the vertices drawn afterwards. It does this by fiddling around in the matrix which is set up, and when you're just drawing just one object it isn't a problem (that's what you want after all).
It gets trickier with two objects because the matrix is then altered, and your second object gets influenced. How to work around this? Use the matrix stack thingy *whatever*. Functions needed?

sceGumPushMatrix() and sceGumPopMatrix().

So, something like the following _will_ work:
Code:

      sceGumPushMatrix();
         if(pad.Buttons != 0)
            if(pad.Buttons & PSP_CTRL_SQUARE)
               sceGumTranslate(&pos);

      sceGumDrawArray(GU_TRIANGLES,GU_TEXTURE_32BITF|GU_COLOR_8888|GU_VERTEX_32BITF|GU_TRANSFORM_3D,2*3,0,vertices);
      
      sceGumPopMatrix();
      sceGumPushMatrix();

         if(pad.Buttons != 0)
            if(pad.Buttons & PSP_CTRL_CIRCLE)
               sceGumTranslate(&pos2);
      
      sceGumDrawArray(GU_TRIANGLES,GU_TEXTURE_32BITF|GU_COLOR_8888|GU_VERTEX_32BITF|GU_TRANSFORM_3D,2*3,0,cursor_vertices);
      
      sceGumPopMatrix();


Now, this is my way of doing things and I don't know if there's a better way, but it works like a charm. Multiple objects, simple functions, sounds like a sweet solution to me.

People who'd like to see a running example, check http://www.jlpro.nl/wacco/cube.c (cube, lights, controller combined with two objects)
It's kinda sloppy and messy but that's because I was trying out multiple things at the same time. Just start screwing around with it like I'm doing.

Enjoy :)
Back to top
View user's profile Send private message
ReKleSS



Joined: 18 Jun 2005
Posts: 73
Location: Melbourne, Australia

PostPosted: Sun Sep 11, 2005 9:37 pm    Post subject: Reply with quote

Heh... you've come up with the standard OpenGL approach to dealing with matrices :p Since the PSP 3d API is somewhat similar to OGL, you might want to read up on that...
-ReK
Back to top
View user's profile Send private message
wacco



Joined: 24 Aug 2005
Posts: 3

PostPosted: Sun Sep 11, 2005 10:21 pm    Post subject: Reply with quote

I did read up on that, I'm currently trying things in OpenGL / Glut. If it works, I try the same method on the psp. :P

Only thing I noticed is that the depth buffer gets screwed up in this way, maybe it's just something I did wrong or it's really the push/pop matrix that prevents this from working. Idunno, but whatever. I'll continue playing in OpenGL first. :)

Btw, does anybody know if there are functions like glutGet(GLUT_ELAPSED_TIME) in the pspsdk? Could really use that one...
Back to top
View user's profile Send private message
holger



Joined: 18 Aug 2005
Posts: 204

PostPosted: Thu Sep 15, 2005 3:24 am    Post subject: Re: Control responce slow Reply with quote

wacco wrote:
if(pad.Buttons != 0) {
if(pad.Buttons & PSP_CTRL_SQUARE) val2 = -2;
} else val2 = -1;
cursor_vertices[1].x = val2;


Try using latched events and investigate the Make/Break bits instead of the corresponding Button bits if you don't want to miss events between frames. See pspgl's glut.c for an example.
Back to top
View user's profile Send private message
holger



Joined: 18 Aug 2005
Posts: 204

PostPosted: Thu Sep 15, 2005 3:27 am    Post subject: Reply with quote

wacco wrote:
Btw, does anybody know if there are functions like glutGet(GLUT_ELAPSED_TIME) in the pspsdk? Could really use that one...


what about gettimeofday()? You could easily implement glutGet(GLUT_ELAPSED_TIME) using this, see e.g. our Sys_Milliseconds() implementation in pspgl/test-q3/generic/main.c. If you implement a rough glutGet() providing the most commonly used functionalities... patches are welcome!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group