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 

MS free space problem

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



Joined: 09 Nov 2005
Posts: 647

PostPosted: Mon Jul 20, 2009 9:12 pm    Post subject: MS free space problem Reply with quote

Hi Guys,
I have always used this snippet to retrieve Memory Stick space remaining
I don't know how it works:

Code:

void free_ms_memory() {
int memd;

sceIoDevctl("ms0:", 0x02425818, &pbuf, sizeof(pbuf), 0, 0);
for (memd=0; memd<5; memd++);

freemem = buf[2] * buf[3] * buf[4];
freememx = freemem;
freemem = freemem/1024;
freemem = freemem/1024;

sprintf(filler, "    MS: %d Mb",freemem);
printTextScreen(3, 250, filler, Blue);
sceDisplayWaitVblankStart();
flipScreen();
}
 


Problem is it doesn't work with Memory Sticks 8Gb and over.
Is there a commonly used replacement used for this purpose?
_________________
If not actually, then potentially.
Back to top
View user's profile Send private message
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Wed Jul 22, 2009 3:05 am    Post subject: Reply with quote

It works fine, you are just hitting a overflowing the integer arithmetic. You need to convert your 3 values to 64bit integers.
Back to top
View user's profile Send private message
Art



Joined: 09 Nov 2005
Posts: 647

PostPosted: Wed Jul 22, 2009 8:23 am    Post subject: Reply with quote

thankyou :)
_________________
If not actually, then potentially.
Back to top
View user's profile Send private message
PsPfReAK



Joined: 28 Mar 2009
Posts: 61

PostPosted: Tue Jul 28, 2009 7:28 am    Post subject: Reply with quote

Would this work for the flash0 aswell?
Back to top
View user's profile Send private message Visit poster's website
m0skit0



Joined: 02 Jun 2009
Posts: 226

PostPosted: Tue Jul 28, 2009 7:17 pm    Post subject: Reply with quote

Why would use that on flash0? It's fixed size :P
_________________
The Incredible Bill Gates wrote:
The obvious mathematical breakthrough would be development of an easy way to factor large prime numbers.
Back to top
View user's profile Send private message
slasher2661996



Joined: 22 Feb 2009
Posts: 91
Location: Melbourne Australia ZOMG

PostPosted: Tue Jul 28, 2009 9:12 pm    Post subject: Reply with quote

no it's not. You can partition it from DC
Back to top
View user's profile Send private message
m0skit0



Joined: 02 Jun 2009
Posts: 226

PostPosted: Tue Jul 28, 2009 10:09 pm    Post subject: Reply with quote

Ok, didnt know, sorry.

That code should work on flash partitions too as it uses sceIoDevctl().
_________________
The Incredible Bill Gates wrote:
The obvious mathematical breakthrough would be development of an easy way to factor large prime numbers.
Back to top
View user's profile Send private message
Art



Joined: 09 Nov 2005
Posts: 647

PostPosted: Wed Jul 29, 2009 9:22 am    Post subject: Reply with quote

I still didn't get the thing to work.
I assume the 64 bit integers are long long.
I got a 16Gb MS now.
_________________
If not actually, then potentially.
Back to top
View user's profile Send private message
cory1492



Joined: 10 Dec 2004
Posts: 216

PostPosted: Wed Jul 29, 2009 9:40 am    Post subject: Reply with quote

I've always assumed the actual io command (0x02425818) would be different for different devices, at least it seems to me it is for flushes at any rate.

Going by types.h a 64 bit is either u64 or s64, though signed 64bit should be long long. Are you sure you retyped all the buf/pbuf etc? Is there any particular reason to have that for loop on memd in there as it braces no code? I'd try my own ideas, but I lack anything over 4G.
Back to top
View user's profile Send private message
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Wed Jul 29, 2009 3:11 pm    Post subject: Reply with quote

Urm, what I meant when I said use 64bit ints is to keep the buf as is (leave as 32bit ints) then when doing the calculation cast each element to a 64bit int.
Back to top
View user's profile Send private message
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Wed Jul 29, 2009 11:15 pm    Post subject: Reply with quote

TyRaNiD wrote:
Urm, what I meant when I said use 64bit ints is to keep the buf as is (leave as 32bit ints) then when doing the calculation cast each element to a 64bit int.


When I divide u64 by a smaller value like (u64)1024 it crashes.
Back to top
View user's profile Send private message
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Thu Jul 30, 2009 2:29 am    Post subject: Reply with quote

That is unfortunate ;)
Back to top
View user's profile Send private message
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Thu Jul 30, 2009 3:14 am    Post subject: Reply with quote

TyRaNiD wrote:
That is unfortunate ;)

...
Even if I assign the result to a u64.
However if I have something like (u64var1 - u64var2)/small then it works. Presumably since the numerator equates to a 32bit value, like what usually occurs when using the RTC timer values in calculations.
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