| View previous topic :: View next topic |
| Author |
Message |
Art
Joined: 09 Nov 2005 Posts: 647
|
Posted: Mon Jul 20, 2009 9:12 pm Post subject: MS free space problem |
|
|
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 |
|
 |
TyRaNiD
Joined: 18 Jan 2004 Posts: 918
|
Posted: Wed Jul 22, 2009 3:05 am Post subject: |
|
|
| 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 |
|
 |
Art
Joined: 09 Nov 2005 Posts: 647
|
Posted: Wed Jul 22, 2009 8:23 am Post subject: |
|
|
thankyou :) _________________ If not actually, then potentially. |
|
| Back to top |
|
 |
PsPfReAK
Joined: 28 Mar 2009 Posts: 61
|
Posted: Tue Jul 28, 2009 7:28 am Post subject: |
|
|
| Would this work for the flash0 aswell? |
|
| Back to top |
|
 |
m0skit0
Joined: 02 Jun 2009 Posts: 226
|
Posted: Tue Jul 28, 2009 7:17 pm Post subject: |
|
|
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 |
|
 |
slasher2661996
Joined: 22 Feb 2009 Posts: 91 Location: Melbourne Australia ZOMG
|
Posted: Tue Jul 28, 2009 9:12 pm Post subject: |
|
|
| no it's not. You can partition it from DC |
|
| Back to top |
|
 |
m0skit0
Joined: 02 Jun 2009 Posts: 226
|
Posted: Tue Jul 28, 2009 10:09 pm Post subject: |
|
|
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 |
|
 |
Art
Joined: 09 Nov 2005 Posts: 647
|
Posted: Wed Jul 29, 2009 9:22 am Post subject: |
|
|
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 |
|
 |
cory1492
Joined: 10 Dec 2004 Posts: 216
|
Posted: Wed Jul 29, 2009 9:40 am Post subject: |
|
|
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 |
|
 |
TyRaNiD
Joined: 18 Jan 2004 Posts: 918
|
Posted: Wed Jul 29, 2009 3:11 pm Post subject: |
|
|
| 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 |
|
 |
Torch

Joined: 28 May 2008 Posts: 842
|
Posted: Wed Jul 29, 2009 11:15 pm Post subject: |
|
|
| 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 |
|
 |
TyRaNiD
Joined: 18 Jan 2004 Posts: 918
|
Posted: Thu Jul 30, 2009 2:29 am Post subject: |
|
|
| That is unfortunate ;) |
|
| Back to top |
|
 |
Torch

Joined: 28 May 2008 Posts: 842
|
Posted: Thu Jul 30, 2009 3:14 am Post subject: |
|
|
| 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 |
|
 |
|