Skip to: Site menu | Main content


Welcome to PSP-Programming.com, a place for developers to get together.

Welcome to the forums. Here you can find other user tutorials as well as homebrew releases and the source code repository. You can also ask for help with your code here and post your own homebrew!

PSP-Programming.com Forums
February 11, 2012, 01:04:50 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

News: Check out the Code Section!
Home Help Search Shop Login Register
Digg This!
Pages: [1]
Print
Author Topic: PSP_CTRL_* is being too responcive. Timer to slow it down?  (Read 2426 times)
bunny
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 15
0.00 points

View Inventory
Send Money to bunny

View Profile
« on: August 09, 2006, 01:24:58 PM »

Hi! Today I started making a video game for the psp. It is a simple puzzle game and right now I am about 5% through, if even that.

An example piece of code I have right now is:

   SceCtrlData pad;
   while(1) {
      sceCtrlReadBufferPositive(&pad, 1);

      if(pad.Buttons & PSP_CTRL_UP) {
         flipScreen();
         convert(x, y, outX, outY);
         blitAlphaImageToScreen(0 ,0 ,27, 27, grid, outX, outY);

         if (y == 0 && x < 9) {
            x++;
         } else if (y == 9 && x > 0) {
            x--;
         } else if (x == 0 && y > 0) {
            y--;
         } else if (x == 9 && y < 9) {
            y++;
         }

         convert(x, y, outX, outY);
         blitAlphaImageToScreen(0 ,0 ,27, 27, gun, outX, outY);
         flipScreen();
      }

grid is the background square, and gun is the object moving around.

The game is a 10x10 grid and on the outskirts of the grid the object moves around clockwise or counter-clockwise depending on what the user pushes.



My problem is when I push up, even if it moves around like I want it to, it moves way to fast. If I tap up slightly it might move 3 squares when I really want it to move 1 squares distance. I'm glad the psp is being responsive but is there a way to slow it down?

I tried to run a while loop in between and just have a number count up to slow it down, and surprisingly it had little to no effect on the speed. Also, I really don't want to put excess number crunching that is not required.

Is there a time pause command I can use or a library that can do that anyone knows about?


Also, when I hold down a button to move my object around the top 5 pixels horizontal flickers a lot which makes the background look bad. Anyone know the solution to this problem as well?


Thank you for any help!! Very Happy
Logged


nathan42100
Give miinaturvat Points!
Administrator
Hero Member
*

Karma: +32/-2
Offline Offline

Posts: 1161
934.18 points

View Inventory
Send Money to nathan42100


View Profile WWW
« Reply #1 on: August 09, 2006, 01:37:15 PM »

well, to solve the flickering, you need to have a VSync in there. You could also put a delay (for loop that loops a vsync) for each control. There is probably other ways if you don't want the action to loop.
Logged

All of my work is released under the Creative Commons Attribution-Noncommercial-Share Alike 3.0 License.
dn ʎɐʍ sıɥʇ
Help support my computer projects!

bunny
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 15
0.00 points

View Inventory
Send Money to bunny

View Profile
« Reply #2 on: August 09, 2006, 02:08:41 PM »

Ok I put in sceDisplayWaitVblankStart(); and it fixed the problem right up. Thank you! Smile

Now how do I put a delay exactly? Basically, that is what I was trying to ask the whole time.

I'm new to programming, so I have to apologize if the question has an easy solution, and I am just being stupid. sorry
Logged
Soulkiller
Miinaturvat Rules!
Hero Member
*****

Karma: +77/-6
Offline Offline

Posts: 1151
83.50 points

View Inventory
Send Money to Soulkiller


View Profile
« Reply #3 on: August 09, 2006, 02:26:18 PM »

nathan said it
Quote

....You could also put a delay (for loop that loops a vsync) for each control....

put a vsync inside a for loop and loop it for X amount of times everytime a button is pressed Wink
Logged

bunny
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 15
0.00 points

View Inventory
Send Money to bunny

View Profile
« Reply #4 on: August 09, 2006, 02:32:31 PM »

ohhhh!!!  Thank you!! Very Happy

*bonks on the head* duh  Laughing  Cool  Razz
Logged
SG57
Sr. Member
****

Karma: +7/-37
Offline Offline

Posts: 474
1140.80 points

View Inventory
Send Money to SG57


View Profile
« Reply #5 on: August 09, 2006, 10:41:52 PM »

Or save yourself the time and variables:

Code:

sceKernelDelayThread(1000000 * #ofSECONDStoDELAY);


That will delay the thread for hte amount specified in microseconds (?).  So delaying 1 second would be 1,000,000 microseconds.  2 would be 1,000,000 * 2, etc...
Logged
Pages: [1]
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.18 seconds with 30 queries.
Sister Sites: Guitar Hero 4   BrokeniTouch.com