Author Topic: Is possible to get NUMBER OF BLOCKS TOTAL / USED?  (Read 764 times)

0 Members and 1 Guest are viewing this topic.

Offline MIRKOSOFT

  • C128 user
  • ******
  • Posts: 785
  • Age: 33
  • Location: Zvolen
  • Activity:
    3.6%
  • Country: sk
  • Reputation: 188
  • Gender: Male
  • C128 programmer
  • With us since: 13/02/2009
    YearsYearsYearsYears
    • View Profile
    • MIRKOSOFT
Is possible to get NUMBER OF BLOCKS TOTAL / USED?
« on: May 06, 2011, 07:16 AM »

Hi!


I need to know number of blocks TOTAL & USED, is it possible?


It's not problem to read how many blocks are free, how many blocks program requires...


I need to know TOTAL BLOCKS on device and USED BLOCKS of device, e.g.


Partition 1 of CMD HD:
- has 62128 BLOCKS FREE
- has ? BLOCKS TOTAL
- has ? BLOCKS USED


Many thanks for all replies, help and comments!


Miro
« Last Edit: May 06, 2011, 07:17 AM by MIRKOSOFT »
MIRKOSOFT of megabytes

Commodore 64 was great, Commodore 128 is bigger, better, faster and more!!!

64ever 128her
sixty-for-ever one-twenty-either

C128 = C64² + more

http://www.mirkosoft.sk

Offline Hydrophilic

  • 128D user
  • *******
  • Posts: 1214
  • Age: 41
  • Location: Earth... still!
  • Activity:
    0%
  • Reputation: 232
  • Gender: Male
  • With us since: 25/01/2007
    YearsYearsYearsYearsYearsYears
    • View Profile
    • H2Obsesson
Re: Is possible to get NUMBER OF BLOCKS TOTAL / USED?
« Reply #1 on: May 08, 2011, 02:31 AM »
I don't know how to get the total used.
 
To get the total size, use the G-P command and check bytes 27-29 returned.  These are number of 512-byte sectors.  Also, I believe this is unformatted size.  The formatted size (available to user for storing data) will be less.
 
Also, SD2IEC devices like uIEC also support G-P command, but because they can be larger than 16MB, they report the total in bytes 22-25.  Same as before, it is the number of 512-byte sectors, and it is the unformatted (raw) size.
 
The G-P command is issued like:
 
PRINT#15,"G-P"CHR$(n)
 
Where is n is the partition number.  I don't own a CMD-HD, but I believe n should be 1 to X (where X is total number of partitions).  For SD2IEC device, n is 0 to X-1.
 
Device will return 31 bytes of data:
 
Byte 0: Partition type (1=native, 2~5=15x1 disk)
Byte 1: 0 (you probably got disk error if this is not 0)
Byte 2: Partition number
Byte 3~18: Partition name
Byte 19~21: Starting sector (high byte first)
Byte 22~25: Total size (SD2IEC) high byte first
Byte 26: Reserved
Byte 27~29: Total size (CMD-HD) high byte first
Byte 30: 13 (return)
 
I've attached a simple program I wrote and tested with SD2IEC device, uIEC.  It is a BASIC program.  I tested in C128 mode, but it should work on other Commodore computers with a little change (remove BANK command, and maybe change RAM address used).
 
 
I'm kupo for kupo nuts!

 



Back to top