Disktool - Commandline tool for diskimage manipulation

You need an actual VIC.

Moderator: Moderators

Post Reply
User avatar
Schlowski
NoMess!
Posts: 892
Joined: Tue Jun 08, 2004 12:20 pm

Disktool - Commandline tool for diskimage manipulation

Post by Schlowski »

As per request of Kananga I extracted the disk image manipulation parts out of BasEdit and made a little standalone console application.
Disktool can be used to add, extract, delete, check and list files inside diskimages and even to create new, empty diskimages.

Code: Select all

      Console.WriteLine("Usage: disktool -command diskimage [cbmfilename [hostfilename]]")
      Console.WriteLine("   -command")
      Console.WriteLine("      -c create image")
      Console.WriteLine("      -x extract file")
      Console.WriteLine("      -a add file")
      Console.WriteLine("      -l list files")
      Console.WriteLine("      -e exists file")
      Console.WriteLine("      -d delete file")
      Console.WriteLine("")
      Console.WriteLine("   exit codes")
      Console.WriteLine("       0 OK")
      Console.WriteLine("      -1 diskimage already exists")
      Console.WriteLine("      -2 diskimage does not exist")
      Console.WriteLine("      -3 filename does not exist")
      Console.WriteLine("      -4 error writing file to diskimage")
      Console.WriteLine("      -5 error extracting file from diskimage")
      Console.WriteLine("      -6 error deleting file from diskimage")
      Console.WriteLine("      -999 unknown command")
Grab it here: http://www.stojalowski.de/DiskTool/disktool.zip

Needs an installed .NET Framework 3.5, comes as a single exe and without any warranties :lol:
Last edited by Schlowski on Mon Jul 05, 2010 11:19 am, edited 1 time in total.
Kananga
Vic 20 Afficionado
Posts: 317
Joined: Mon Mar 08, 2010 2:11 pm

Post by Kananga »

Great, thanks a lot!
If all my wishes came true so fast...
Buy the new Bug-Wizard, the first 100 bugs are free!
User avatar
nbla000
Salmon Run
Posts: 2582
Joined: Thu Oct 13, 2005 8:58 am
Location: Italy

Post by nbla000 »

It could be very useful, thanks.
Mega-Cart: the cartridge you plug in once and for all.
User avatar
hawk
Vic 20 Afficionado
Posts: 342
Joined: Mon Jun 20, 2005 7:32 pm

Post by hawk »

Hi Schlowski,

This is great. I've just been setting up a new development environment using Code::Blocks, and I wanted to add the post compile steps to load files into a disk image after they were built. It worked great, but I can't believe I had to download 60MB of .NET Framework! :shock:

Anyway, I was wondering whether you'd post your source so I can recompile for OSX?

Thanks
User avatar
Schlowski
NoMess!
Posts: 892
Joined: Tue Jun 08, 2004 12:20 pm

Post by Schlowski »

The good part about the 60MB .NET Framework download is that you have to do it only once for DiskTool and BasEdit :-) And a lot of other programs like PRG Starter...

Anyways, I put together a ZIP with my sources, you can get it here:

http://www.stojalowski.de/DiskTool/DiskTool_Src.zip

It's the complete VB2008 project folder - be warned, my sources are not made for the public so you will have some fun trying to understand them :twisted:

If you manage to make a running version for OSX (and maybe for Linux either) please share it with me so I can bundle it with the Windows version!
Boray
Musical Smurf
Posts: 4064
Joined: Mon May 03, 2004 10:47 am

Post by Boray »

I took a glance at your source and thought I would see something like:

Code: Select all

Dim d81tracks() As Integer = {0, 0, &H2800, &H5000, &H7800, &HA000, &HC800, &HF000, &H11800, &H14000, &H16800, &H19000, &H1B800, &H1E000, _
    &H20800, &H23000, &H25800, &H28000, &H2A800, &H2D000, &H2F800, &H32000, &H34800, &H37000, &H39800, &H3C000, &H3E800, &H41000, _
    &H43800, &H46000, &H48800, &H4B000, &H4D800, &H50000, &H52800, &H55000, &H57800, &H5A000, &H5C800, &H5F000, &H61800, _
    &H64000, &H66800, &H69000, &H6B800, &H6E000, &H70800, &H73000, &H75800, _
    &H78000, &H7A800, &H7D000, &H7F800, &H82000, &H84800, &H87000, &H89800, &H8C000, &H8E800, &H91000, &H93800, &H96000, &H98800, &H9B000, &H9D800, _
    &HA0000, &HA2B00, &HA5000, &HA7800, &HAA000, &HAC800, &HAF000, &HB1800, &HB4000, &HB6800, &HB9000, &HBB800, &HBE000, &HC0800, &HC3000, &HC5800}
...but I couldn't see it so I guess our approaches was quite different ;)
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
User avatar
hawk
Vic 20 Afficionado
Posts: 342
Joined: Mon Jun 20, 2005 7:32 pm

Post by hawk »

Schlowski wrote:It's the complete VB2008 project folder - be warned, my sources are not made for the public so you will have some fun trying to understand them :twisted:
Oh bugga...I should have asked what language it was written in before even considering re-compilation.

I'm guessing that VB will require a complete re-write into OSX. I've only just started using OSX, so maybe it's a nice project to cut my teeth on. I'll have a look at the source and decide. I'm currently downloading Visual Studio Express 2008, which I'm hoping will allow me to view the project.
Schlowski wrote:If you manage to make a running version for OSX (and maybe for Linux either) please share it with me so I can bundle it with the Windows version!
I'm more likely to come up with a generic C/C++ version that would compile for multiple platforms since it's just a command line tool.

I'm really surprised that something like this didn't exist already, but when I went searching, all I found were GUI tools, and some of those were DOS style.
User avatar
Schlowski
NoMess!
Posts: 892
Joined: Tue Jun 08, 2004 12:20 pm

Post by Schlowski »

@Hawk:
VB 2008 Express is ok, that's what I've used.
DiskTool is a spin-off from my BasEdit, that's the reason why it's VB and .NET. If I would have aimed for this tool from scratch I would have used other programming tools - but definately not C/C++ as I hate that languages :-) Maybe Purebasic as it is fast and makes very small executables...

You could take a look at c1541.exe which is part of VICE, I think it does similar things.

@Boray:

Code: Select all

   Public Sub InitD81(Optional ByVal NumTracks As Byte = 40)
      Dim t As Integer

      For t = 1 To 40
         TrackTable(t) = 40
         TrackTable(t + NumTracks) = 40
      Next
      TracksPerSide = NumTracks
      Tracks = CByte(NumTracks * 2)
      InfoTrack = 40
      InfoSector = 0
      DirTrack = 40
      DirSector = 3
      BAMTrack1 = 40
      BAMSector1 = 1
      BAMTrack2 = 40
      BAMSector2 = 2
      SectorSize = 256
      DirInterleave = 1
      DataInterleave = 1
      RealSave = True
   End Sub
I calculate offsets from the TrackTable array when needed:

Code: Select all

   Public Function CalcSector(ByVal Track As Integer, ByVal Sector As Integer) As Integer
      Dim t As Integer
      Dim Erg As Integer

      Erg = 0
      For t = 1 To Track - 1
         Erg = Erg + TrackTable(t)
      Next
      Erg = Erg + Sector
      CalcSector = Erg
   End Function
Regarding the D81 this is a little bit overcomplicated as every track has 40 sectors, but this routine is used for the other formats, too, which have different number of sectors per track on different track numbers :-)
Boray
Musical Smurf
Posts: 4064
Joined: Mon May 03, 2004 10:47 am

Post by Boray »

Schlowski wrote: Regarding the D81 this is a little bit overcomplicated as every track has 40 sectors, but this routine is used for the other formats, too, which have different number of sectors per track on different track numbers :-)
Oh, I used the same way as for the D64 too, copying the whole table from the format description. If all sectors are equally long on d81, then maybe I should have used a little routine to save some bytes insead...
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
Boray
Musical Smurf
Posts: 4064
Joined: Mon May 03, 2004 10:47 am

Post by Boray »

Did that and the file got 1024 bytes smaller. Must have gone over some kilobyte threshold.

Code: Select all

                    For t As Integer = 1 To 80
                        track(t) = &H2800 * (t - 1)
                    Next
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
Boray
Musical Smurf
Posts: 4064
Joined: Mon May 03, 2004 10:47 am

Post by Boray »

hawk wrote: Oh bugga...I should have asked what language it was written in before even considering re-compilation.
Maybe that 60MB download isn't that a bad idea after all. ;) Are you talking about the original .NET download or a MONO download for OSX?
http://www.mono-project.com/
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
User avatar
Schlowski
NoMess!
Posts: 892
Joined: Tue Jun 08, 2004 12:20 pm

Post by Schlowski »

I don't think DiskTool will run out of the box using Mono...

My tests concerning BasEdit where a little bit disappointing, it starts but as soon as you do something it crashes on various places. I gave up after one afternoon/evening full of little tweaks and workarounds as I didn't had the feeling that it was going ahead. Some other guy insisted in trying to get it run with Mono so I handed him the sources but this was some weeks ago and beside some starting questions and tests on the first two days I did not hear anything new from him...

My experiences with Mono are twofolded - I think if you want something to run on different OSes you should keep that in mind from the very beginning and develop using Mono instead of VB.NET or C#.NET. There are lots of traps, starting with dir separators (\ and /), case sensitive filesystems (what a strange idea...), problems with ANSI/Unicode characters (CHR and ASC functions behave very differently on Windows/OSX/Linux) and so on, and so on...

So my conclusion about Mono was the same as I have about C. Multi-platform-programs are possible, but you have to live with so many constraints that is is far from being fun or even easy.

(I have an iMac and a Linux partition, I tried to work with both of them, but I returned to Windows after a while as it seemed to fit me more than the other systems. Just as a note so nobody can say I would only criticise what I don't know! I simply can't get used to this whole *nix stuff as I can't get used to C-like languages. I'm a Windows guy and I'm a Basic guy :-) )
Boray
Musical Smurf
Posts: 4064
Joined: Mon May 03, 2004 10:47 am

Post by Boray »

Hmm, maybe PRG Starter is full of bugs when running on Linux then... But I have disabled many things when not running on Windows.
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
User avatar
hawk
Vic 20 Afficionado
Posts: 342
Joined: Mon Jun 20, 2005 7:32 pm

Post by hawk »

Schlowski wrote:I don't think DiskTool will run out of the box using Mono...
If it comes to that, I could do my development in Windows under VMware Fusion, but I'm trying to move across to native OSX for as much as possible. Hence the reason I'm using Code::Blocks...I can run it under Windows, Linux and OSX.

I'm not sure how far my efforts will go. I'm looking at a manual translation into either C or C++. Not a difficult task...just a time consuming one.
Post Reply