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 

[NOOB] what is * after datatype

 
Post new topic   This topic is locked: you cannot edit posts or make replies.    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
the underminer



Joined: 03 Oct 2005
Posts: 124
Location: Netherlands

PostPosted: Sat Jun 14, 2008 6:50 pm    Post subject: [NOOB] what is * after datatype Reply with quote

I am very new to C for PSP, but have quite some experience with lua.

In the image tutorial on psp-programming this datatype was used:

Code:

Image* ourImage;


What's that * doing there?
Also, these forums don't seem to have any structure. (all C related stuff goes in the same place). Is there a subsection for noob stuff like this?[/code][/i]
_________________
Behold! The Underminer got hold of a PSP
Back to top
View user's profile Send private message
hlide



Joined: 10 Sep 2006
Posts: 750

PostPosted: Sat Jun 14, 2008 7:14 pm    Post subject: Reply with quote

Google "C pointer tutorial". I strongly encourage you to find a good tutorial on C before programming it. C is kinda a high level assembler in some aspects. The pointer through "*" is one of those aspects.

Any variables or functions has an address and they can be accessed through a pointer :

int count1; <--- defines an integer variable

count1 = 10; <--- set the value of this variable to 10

int *count2; <--- defines a pointer on an integer value

count2 = &count1; <--- set the pointer to the address of count1 where 10 was set

*count2 = 20; <--- set the new value of count1 through the pointer count2 to 20

printf("%d", count1); <--- displays teh value of count1, that is, 20 !

Now you should really find a good C tutorial to continue.
Back to top
View user's profile Send private message
the underminer



Joined: 03 Oct 2005
Posts: 124
Location: Netherlands

PostPosted: Sat Jun 14, 2008 7:34 pm    Post subject: ok, I will Reply with quote

Good advise. I will do that after this is de-mystified:

I thought I'd edit the timer program to use a proper timer instead of Vblanks to set the value of the counter (now timer)
I looked through the source and found pspsystimer.h in the kernel dir.
I used the functions inside that file.
This is the code:

Code:

#include <pspkernel.h>
#include <pspdebug.h>
#include <pspdisplay.h>
#include <pspctrl.h>
#include <pspsystimer.h>
PSP_MODULE_INFO("timer",0,1,1);

#define printf pspDebugScreenPrintf

// callbacks omitted

int main(){
   pspDebugScreenInit();
   SetupCallbacks();
   int timerId = sceSTimerAlloc();
   int timerValue;
   int i;
   SceCtrlData pad;
   if(timerId<0){
      printf("timer not initialized");
   }else{
      
      printf("Press [X] To Start the Timer");
      while(1){
          sceCtrlReadBufferPositive(&pad, 1);
         if(pad.Buttons & PSP_CTRL_CROSS){
            break;
         }
      }
      sceSTimerStartCount(timerId);
      while(1) {
             sceCtrlReadBufferPositive(&pad, 1);
             if(pad.Buttons & PSP_CTRL_CIRCLE) {
                   break;
             }
         pspDebugScreenClear();
         sceSTimerGetCount(timerId, &timerValue);
            printf("Press [O] To Stop the Timer\n");
             printf("timer: %i", timerValue);
          for(i=0; i<5; i++) {
                       sceDisplayWaitVblankStart();
                }
      }
         pspDebugScreenClear();
         sceSTimerGetCount(timerId, &timerValue);
         printf("timer Finished.");
         printf("Final Count: %i", timerValue);
   }
   sceKernelSleepThread();

   return 0;
}


The compiler didn't complain but when running the eboot from irShell I got a 8002013C error. Google says that's a 'library not found' error. Supposedly caused by the pspsystimer.h.
But the file is in the same directory as pspkernel.h so why shouldn't it be able to find it?
_________________
Behold! The Underminer got hold of a PSP
Back to top
View user's profile Send private message
Pirata Nervo



Joined: 09 Oct 2007
Posts: 409

PostPosted: Sat Jun 14, 2008 9:31 pm    Post subject: Reply with quote

the other of your LIBS in your Makefile can be wrong
_________________

Upgrade your PSP
Back to top
View user's profile Send private message
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Sat Jun 14, 2008 9:44 pm    Post subject: Reply with quote

Unfortunately SysTimer is only for kernel application, you cannot use it in this fashion. What you probably want is the RTC stuff (psprtc.h) and use something like sceRtcGetCurrentTick to get a high resolution timer (you can find how many ticks per second are used with sceRtcGetTickResolution).

Of course that being said you really should know how to code C before doing anything as complex as this :)
Back to top
View user's profile Send private message
Pirata Nervo



Joined: 09 Oct 2007
Posts: 409

PostPosted: Sat Jun 14, 2008 10:17 pm    Post subject: Reply with quote

I never understood why can a library in wrong order can have the same error type :|

Everytime I get that error I need to searh my whole code for a kernel-only function and then I need to check the makefile too :/
_________________

Upgrade your PSP
Back to top
View user's profile Send private message
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Sat Jun 14, 2008 11:43 pm    Post subject: Reply with quote

The issue is if it is a user application those libraries don't exist to be linked to, hence the error. The real issue is with the SDK and in part to the way it developed. Really we need a user only flag (we already have a kernel only flag) which ensures that you can only link in user mode libraries and this issue would go away :)
Back to top
View user's profile Send private message
Pirata Nervo



Joined: 09 Oct 2007
Posts: 409

PostPosted: Sun Jun 15, 2008 8:00 am    Post subject: Reply with quote

oh I got it now, thanks
_________________

Upgrade your PSP
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   This topic is locked: you cannot edit posts or make replies.    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