whats that command?Zitat:
Zitat von ropost
Printable View
whats that command?Zitat:
Zitat von ropost
HiZitat:
Zitat von myschoo
here you go:)
Code:int get_free_space_ms()
{
int free_space;
int buf[5];
int *buf_pointer = buf;
sceIoDevctl("ms0:", 0x02425818, &buf_pointer, sizeof(buf_pointer), 0, 0);
free_space = buf[2] * buf[3] * buf[4];
free_space = free_space/1024;//to kb
free_space = free_space/1024;//to mb
return free_space;
}
hey thx ropost! :tup:
Hi Guys, I'm creating a menu for an HB I'm currently developing and got stuck in one thing.
I wanna create a very large menu coming from an array (may have 50+ items) and would like to be able to display it in one go on the screen, and let the user scroll over it showing a selector over the item selected, just like IRSHELL when it displays the list of remote controls.
Actually I'm having two probs.
First is that I can't seem to be able to create a char array the same way I create an int array like
If I do the same with char, the program won't compileCode:int myArr = {1,2,3,4,5};
And second is that I have no idea about how to make my list scroll when the users uses up and down arrows as well as how to know which position I have to show my selector. I guess I can figure ou the position by getting the last position plus x pixels. But the scrolling thing, I have no idea how to do.
Can anyone help me on that? Even if it's pointing me out to some code samples?
Thanks,
Marcos
You can't initialize an int array that way.
is properCode:int myArr[] = {1,2,3,4,5};
And as for the second one...well, I've written two different scrolling systems. One is licensed under the GPL, so if you want to license your software under the GPL, go look up the source for PSPComic (it's not pretty, but it gets the job done). The other one I never released because the program it was in was unstable (never did figure out why), although the scrolling code works very well and is stable.
I'm not totally sure if this is right, but I think to do a list you need to do...
Would this be correct? And if it is, would it be possible to instead use char list[][] and let the compiler work out the correct value? Finally, would I be correct in ending at ten, or should I stop at nine? I'm not sure if using a 2d array needs a NULL pointer in the list[10][10] as a normal array would?Code:char list[10][10] = {"one", "two", "three"... "nine", "ten"}
-Aura
It's only strings (i.e., an array of chars) that need a NULL value at the end.
char list[][] isn't valid but this is char list[][10]. though it'd be easier to useZitat:
Zitat von Auraomega
char *list[10] = {"one", "two", "three"..........};
wich number stands for wich device type?Code:/**
* Get the device type of the currently opened file descriptor.
*
* @param fd - The opened file descriptor.
*
* @return < 0 on error. Otherwise the device type?
*/
int sceIoGetDevType(SceUID fd);
Well, there is a question mark at the end of that statement, so they most likely aren't known.
I'm thinking about removing most of the stuff in the graphics.c, and leaving myself with just the code to draw images, if I was to do this, would it reduce the size of program overall or would the reduction be negligable?
Also, is it possible to draw a .png on the screen when its size is unknown? If its not, is there any way I can check the size of the file in the code?
Thanks.
-Aura
ropost:
maybe just try to open diffrent files from f0, f1, ms0 then use that function and then print on screen the variables so you will see what is returned by what file
hiZitat:
Zitat von _dysfunctional
i didn't saw that:)
@above
Hi
I guess u mean the graphics.c from psp-programing. Look at the Image Data Structure and then change the blit function , not so difficult , you will see:)
If you don't find it , say it and I re download the files:)
I'm using a different one to the one from the tutorials on psp-programming, I'm using one that allows to blit from memory, but anyway, I'm not to fussed about that, all I need to do is blit an image of variable size to the screen, I'm not going to know what the size is, so I either need a function that can determine the dimensions, or some logical way of finding this out so as to feed it to graphics.c in the form of a variable.Zitat:
Zitat von ropost
I've been unable to work out a way using the above 2 options, and my knowledge on images is close to nothing, so I'm not aware if theres an easy way of doing this or not...
-Aura
Well, most image formats (Including PNG) have a header which is located at the beginning of the file. This contains the width and height. I'd read up more on the PNG format.
Your going to need to obtain the image dimensions at the point were you load it. Once it's in memory you can't really tell what the dimesions are because the image is just stored as a linear array of pixel values.
Hello, is there any way in the PSP to get the GMT+0 time? The fac is, I'm using sceRtcGetCurrentClockLoca lTime to get the local time, but this is the time from my PSP, I'd ike toget the Greenwitch Mean Time and not the local time.
Is that possible? I might be missing something on the PSP functions, but I'm sure it must be there.
Thanks
http://psp.jim.sh/pspsdk-doc/psprtc_...e31e0e776a7ad9
UTC = GMT (more or less)
When you display the time, Plus or Minus the hours before you display it to get GMT. It may sound a bit crude but i dunno how else.Zitat:
Zitat von placo23
Hi, I'm a long time lurker, but I decided to join to help out people, as I have a fairly good knowledge of C for the PSP.Zitat:
Zitat von Auraomega
Anyway, if you look at the structure of an image, you can see the dimensions of the image are already there.
typedef struct
{
int textureWidth; // the real width of data, 2^n with n>=0
int textureHeight; // the real height of data, 2^n with n>=0
int imageWidth; // the image width
int imageHeight;
Color* data;
} Image;
Just use Image.imageWidth and Image.imageHeight.
It is even better , dunno way u should call some functions instead of doing y + xZitat:
Zitat von JaSo PsP
I just used sceRtcGetCurrentClock(&rt ime,0); and it worked like a charm!
Thought I didn't understand you solution hallo007. Could you post some sort of example so I can understand?
Cheers
selected timezone must be saved somewhere... so just findout timezone and use it :tup: ( maybe not even possible :D )
IUt's not about getting the selected timezone, but getting the GMT, the "spot 0" if you like :)Zitat:
Zitat von myschoo
Cheers
yeah, but when you have timezone and real time then you can calculate GMT time also ;)
How would I get a random float between a and b?
float random(float a, float b)
rand()/(float)RAND_MAX*(a > b?a - b: b - a)+(a > b?b:a)
I don't know if this will work on negative numbers. Don't feel like trying to figure it out.
I still don't get it. How would I do that? I mean, I already ave it working as mentioned before, but really would like to see ur example :tup:Zitat:
Zitat von myschoo
Zitat:
Zitat von Slasher
Code:float random( float min, float max )
{
assert( min < max && "The min value is more then the max value, please fix" );
float ratio = static_cast<float>( rand() ) / static_cast<float>( RAND_MAX );
float randomFloat = ( ratio * max ) + min;
return randomFloat;
}
I may have this slightly confused, but if you JUST want to work out GMT then you can use the normal ctime library, I know it only calculates GMT as thats what I used in my original XMBE.Zitat:
Zitat von placo23
If you want the local time, then you can use
I guess it doesn't matter either way seeing as you've already solved it :pCode:sceRtcGetCurrentClockLocalTime(&pt);
-Aura
Not quite. That will return a value from min to max + min.Zitat:
Zitat von yaustar
Should work better.Code:float random( float min, float max )
{
assert( min < max && "The min value is more then the max value, please fix" );
float ratio = static_cast<float>( rand() ) / static_cast<float>( RAND_MAX );
float randomFloat = ( ratio * (max - min) ) + min;
return randomFloat;
}
Also, on a related note, how is static_cast<float> different from (float), other than being C++ only?
Oops, I was off to a meeting when I wrote that :$.Zitat:
Zitat von Archaemic
C style casts can do any of the 4 casts at compile time (static, dynamic, reinterpret and const) but you can't tell just by looking at the code (and can lead to some interesting bugs). By using C++ style casts, you are explicitly saying it should use one particular type of cast.
If that type of cast cannot be used then the compiler will spit out an error forcing the programmer to reconsider why the cast was used and why. Are they meant to be related types? If they are not then why is the code trying to use them in the same context?
So in short, C++ style casts imply code safely and as a side effect, a lot easier to search for in code.
For pspctrl.h, what do I use to do the L button..I know it's not PSP_CTRL_L, because I tried.
Help?
PSP_CTRL_LTRIGGER
EDIT: forum took off the caps 'cos it though I was shouting
Alright, thanks.Zitat:
Zitat von coolguy5678
HIZitat:
Zitat von MrChaos
go to /usr/local/pspdev/psp/sdk/include and there you will find that header and all other sdk functions witch could be very helpful :)
The docs are also online here: http://psp.jim.sh/pspsdk-doc/ (This has to be at least the fifth time I've posted that link)
there is also documentation...
you can also look at it online at: http://psp.jim.sh/pspsdk-doc/
add to your bookmarks ;)
edit holy crap archaemic was faster :( :D
Or you can actually open the header to see for yourself like most programmers do ¬¬. All the documentation linked are generated from the comments in the headers of the SDK.
I've got some troubles with loading png as textures. I've readed around and got the thing of the swizzling.
So I put my swizzle and swizzle_fast functions in the bottom of main.c, declare them in main.h, enable thethen I do my loading with the code (before the main loop) like that:Zitat:
sceGuTexMode( GU_PSM_8888, 0, 0, 1);
and in the draw loop there'sZitat:
myimage = loadImage("texture.png");
swizzle(myimage);
as debug I get that the texture is swizzled, but it does not work, as when I enable the sceGuTexMode to 1 I get the image completely messed up (dots, random colors, it looks very bad), if I set to 0 (as if there is no swizzling) i get a "less messed" image, it's just panned with some offset, mirrored, and got junkie colors only on the topmost part of the image.Zitat:
sceGuTexImage( 0, 128, 128, 128,myimage );
sceGumDrawArray( GU_TRIANGLES, GU_TEXTURE_32BITF|GU_COLO R_8888|GU_VERTEX_32BITF|G U_TRANSFORM_3D,3*2, 0, name_of_the_vertexes_arra y );
what am I doing wrong?
p.s. I did try sceKernelDcacheWritebackI nvalidateAll(); almost wherever.... same identical result :(
I tried also with a tgaloader library and keeping the main.c code the same the texture in tga format are loaded perfectly, so maybe it's something in the swizzling functions! can you help?
there are my swizzlings:
-= Double Post =-Zitat:
void swizzle( Image* img )
{
if( img->swizzled)
{
//pspDebugScreenPrintf("Alr eady swizzled Image\n");
}
else
{
int type = 4; // 32 - bit pixel format so 4 bytes
long size = img->textureWidth * img->textureHeight * type;
u8* temp = (u8*)malloc(size);
swizzle_fast( temp, (u8*)img->data, (img->textureWidth * type), img->textureHeight );
free(img->data);
img->data = (u32*)temp;
img->swizzled = 1;
//return img;
}
//img->swizzled = 0;
//return img;
}
void swizzle_fast(u8* out, const u8* in, unsigned int width, unsigned int height)
{
unsigned int blockx, blocky;
unsigned int i,j;
unsigned int width_blocks = (width / 16);
unsigned int height_blocks = (height / 8);
unsigned int src_pitch = (width-16)/4;
unsigned int src_row = width * 8;
const u8* ysrc = in;
u32* dst = (u32*)out;
for (blocky = 0; blocky < height_blocks; ++blocky)
{
const u8* xsrc = ysrc;
for (blockx = 0; blockx < width_blocks; ++blockx)
{
const u32* src = (u32*)xsrc;
for (j = 0; j < 8; ++j)
{
*(dst++) = *(src++);
*(dst++) = *(src++);
*(dst++) = *(src++);
*(dst++) = *(src++);
src += src_pitch;
}
xsrc += 16;
}
ysrc += src_row;
}
}
---------- resolved------------------------Zitat:
Zitat von ruspa
i was doing
does not workZitat:
sceGuTexImage( 0, 128, 128, 128,myimage);
....
now I've replaced with
DOES :ROFL:Zitat:
sceGuTexImage( 0, 128, 128, 128,myimage->data);
i'm really rusty on C... (btw never too late)