1VERSION 5.00 2Begin VB.Form MainForm 3 Caption = "LibDsk test app" 4 ClientHeight = 5868 5 ClientLeft = 48 6 ClientTop = 288 7 ClientWidth = 9984 8 LinkTopic = "Form1" 9 ScaleHeight = 5868 10 ScaleWidth = 9984 11 StartUpPosition = 3 'Windows Default 12 Begin VB.CommandButton btnDskForm 13 Caption = "Format" 14 Height = 732 15 Left = 3240 16 TabIndex = 12 17 Top = 5040 18 Width = 1452 19 End 20 Begin VB.ComboBox cbFormat 21 Height = 288 22 Left = 5880 23 Style = 2 'Dropdown List 24 TabIndex = 9 25 Top = 2280 26 Width = 3852 27 End 28 Begin VB.CommandButton btnDsktrans 29 Caption = "Copy" 30 Height = 732 31 Left = 1680 32 TabIndex = 11 33 Top = 5040 34 Width = 1452 35 End 36 Begin VB.TextBox tbRetries 37 Height = 288 38 Left = 2280 39 TabIndex = 8 40 Text = "1" 41 Top = 2280 42 Width = 1212 43 End 44 Begin VB.Frame Frame2 45 Caption = "Target" 46 Height = 2052 47 Left = 5040 48 TabIndex = 18 49 Top = 120 50 Width = 4692 51 Begin VB.ComboBox cbTargetFilename 52 Height = 288 53 Left = 1440 54 TabIndex = 4 55 Top = 360 56 Width = 2652 57 End 58 Begin VB.CommandButton btnTargetBrowse 59 Caption = "..." 60 Height = 252 61 Left = 4200 62 TabIndex = 5 63 Top = 360 64 Width = 252 65 End 66 Begin VB.ComboBox cbTargetDriver 67 Height = 288 68 Left = 1440 69 Style = 2 'Dropdown List 70 TabIndex = 6 71 Top = 720 72 Width = 2652 73 End 74 Begin VB.ComboBox cbTargetCompression 75 Height = 288 76 Left = 1440 77 Style = 2 'Dropdown List 78 TabIndex = 7 79 Top = 1080 80 Width = 2652 81 End 82 Begin VB.Label Label3 83 Alignment = 1 'Right Justify 84 Caption = "Filename" 85 Height = 252 86 Left = 120 87 TabIndex = 21 88 Top = 360 89 Width = 1212 90 End 91 Begin VB.Label Label2 92 Alignment = 1 'Right Justify 93 Caption = "Driver" 94 Height = 252 95 Left = 240 96 TabIndex = 20 97 Top = 720 98 Width = 1092 99 End 100 Begin VB.Label Label1 101 Alignment = 1 'Right Justify 102 Caption = "Compression" 103 Height = 252 104 Left = 120 105 TabIndex = 19 106 Top = 1080 107 Width = 1212 108 End 109 End 110 Begin VB.CommandButton btnDskID 111 Caption = "Identify" 112 Height = 732 113 Left = 120 114 TabIndex = 10 115 Top = 5040 116 Width = 1452 117 End 118 Begin VB.ListBox lbResults 119 BeginProperty Font 120 Name = "Lucida Console" 121 Size = 7.8 122 Charset = 0 123 Weight = 400 124 Underline = 0 'False 125 Italic = 0 'False 126 Strikethrough = 0 'False 127 EndProperty 128 Height = 2076 129 Left = 120 130 TabIndex = 14 131 Top = 2640 132 Width = 9612 133 End 134 Begin VB.Frame Frame1 135 Caption = "Source" 136 Height = 2052 137 Left = 120 138 TabIndex = 13 139 Top = 120 140 Width = 4692 141 Begin VB.ComboBox cbCompression 142 Height = 288 143 Left = 1440 144 Style = 2 'Dropdown List 145 TabIndex = 3 146 Top = 1080 147 Width = 2652 148 End 149 Begin VB.ComboBox cbDriver 150 Height = 288 151 Left = 1440 152 Style = 2 'Dropdown List 153 TabIndex = 2 154 Top = 720 155 Width = 2652 156 End 157 Begin VB.CommandButton btnSourceBrowse 158 Caption = "..." 159 Height = 252 160 Left = 4200 161 TabIndex = 1 162 Top = 360 163 Width = 252 164 End 165 Begin VB.ComboBox cbSourceFilename 166 Height = 288 167 Left = 1440 168 TabIndex = 0 169 Top = 360 170 Width = 2652 171 End 172 Begin VB.Label labelCompression 173 Alignment = 1 'Right Justify 174 Caption = "Compression" 175 Height = 252 176 Left = 120 177 TabIndex = 17 178 Top = 1080 179 Width = 1212 180 End 181 Begin VB.Label labelDriver 182 Alignment = 1 'Right Justify 183 Caption = "Driver" 184 Height = 252 185 Left = 240 186 TabIndex = 16 187 Top = 720 188 Width = 1092 189 End 190 Begin VB.Label labelSourceFilename 191 Alignment = 1 'Right Justify 192 Caption = "Filename" 193 Height = 252 194 Left = 120 195 TabIndex = 15 196 Top = 360 197 Width = 1212 198 End 199 End 200 Begin VB.Label lblProgress 201 Height = 492 202 Left = 4800 203 TabIndex = 25 204 Top = 5160 205 Width = 4932 206 End 207 Begin VB.Label Label5 208 Alignment = 1 'Right Justify 209 Caption = "Override format:" 210 Height = 252 211 Left = 3720 212 TabIndex = 24 213 Top = 2280 214 Width = 2052 215 End 216 Begin VB.Label Label4 217 Alignment = 1 'Right Justify 218 Caption = "Retries in case of error" 219 Height = 252 220 Left = 240 221 TabIndex = 23 222 Top = 2280 223 Width = 1932 224 End 225 Begin VB.Label lblReport 226 Alignment = 2 'Center 227 Height = 252 228 Left = 120 229 TabIndex = 22 230 Top = 4800 231 Width = 9612 232 End 233End 234Attribute VB_Name = "MainForm" 235Attribute VB_GlobalNameSpace = False 236Attribute VB_Creatable = False 237Attribute VB_PredeclaredId = True 238Attribute VB_Exposed = False 239'/*************************************************************************** 240' * * 241' * LIBDSK: General floppy and diskimage access library * 242' * Copyright (C) 2005 John Elliott <seasip.webmaster@gmail.com> * 243' * * 244' * This library is free software; you can redistribute it and/or * 245' * modify it under the terms of the GNU Library General Public * 246' * License as published by the Free Software Foundation; either * 247' * version 2 of the License, or (at your option) any later version. * 248' * * 249' * This library is distributed in the hope that it will be useful, * 250' * but WITHOUT ANY WARRANTY; without even the implied warranty of * 251' * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 252' * Library General Public License for more details. * 253' * * 254' * You should have received a copy of the GNU Library General Public * 255' * License along with this library; if not, write to the Free * 256' * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 257' * MA 02111-1307, USA * 258' * * 259' ***************************************************************************/ 260 261' 262' DSKtools is an example LibDsk client, written in VB, and roughly equivalent 263' to a limited clone of dskform/dskid/dsktrans. There is no error handling; 264' this is example code, not production quality. 265' 266 267' Implementation of the "Reporter" callback 268Implements LIBDSK.reporter 269 270 271Public Sub Reporter_report(ByVal s As String) 272 lblReport.Caption = s 273End Sub 274 275Public Sub Reporter_endreport() 276 lblReport.Caption = "" 277End Sub 278 279 280 281' 282' VB versions of DSKID, DSKTRANS, DSKFORM 283' 284Private Sub btnDskID_Click() 285 Dim Lib As LIBDSK.Library 286 Dim dsk As LIBDSK.Disk 287 Dim geom As LIBDSK.Geometry 288 Set Lib = New LIBDSK.Library 289 Lib.reporter = Me 290 291 Let driver = cbDriver.Text 292 If (driver = "(Auto Detect)") Then 293 Let driver = "" 294 End If 295 Let compress = cbCompression.Text 296 If (compress = "(Auto Detect)") Then 297 Let compress = "" 298 End If 299 300 Set dsk = Lib.open(cbSourceFilename.Text, _ 301 driver, compress) 302 dsk.retries = Val(tbRetries.Text) 303 ' XXX Set forcehead 304 Set geom = dsk.get_geometry() 305 Let compress = dsk.compdesc 306 Let driver = dsk.drvdesc 307 Let comment = dsk.comment 308 lbResults.Clear 309 310 lbResults.AddItem ("Driver: " + driver) 311 If compress <> "" Then 312 lbResults.AddItem ("Compression: " + compress) 313 End If 314 If (geom.fm = 0) Then 315 recmode = "MFM" 316 Else 317 recmode = "FM" 318 End If 319 320 lbResults.AddItem ("Sidedness: " + Str(geom.Sidedness)) 321 lbResults.AddItem ("Cylinders: " + Str(geom.cylinders)) 322 lbResults.AddItem ("Heads: " + Str(geom.heads)) 323 lbResults.AddItem ("Sectors: " + Str(geom.sectors)) 324 lbResults.AddItem ("First sector: " + Str(geom.secbase)) 325 lbResults.AddItem ("Sector size: " + Str(geom.secsize)) 326 lbResults.AddItem ("Data rate: " + Str(geom.DataRate)) 327 lbResults.AddItem ("Record mode: " + recmode) 328 lbResults.AddItem ("R/W gap: 0x" + Hex(geom.rwgap)) 329 lbResults.AddItem ("Format gap: 0x" + Hex(geom.fmtgap)) 330 Let Status = dsk.drive_status(geom, 0) 331 lbResults.AddItem ("Status: " + Str(Status)) 332 If comment <> "" Then 333 lbResults.AddItem ("Comment: " + comment) 334 End If 335End Sub 336 337Private Sub btnDsktrans_Click() 338 Dim Lib As LIBDSK.Library 339 Dim source As LIBDSK.Disk 340 Dim target As LIBDSK.Disk 341 Dim geom As LIBDSK.Geometry 342 Dim geom2 As LIBDSK.Geometry 343 Set Lib = New LIBDSK.Library 344 Lib.reporter = Me 345 346 Let driver = cbDriver.Text 347 If (driver = "(Auto Detect)") Then 348 Let driver = "" 349 End If 350 Let compress = cbCompression.Text 351 If (compress = "(Auto Detect)") Then 352 Let compress = "" 353 End If 354 355 Let tdriver = cbTargetDriver.Text 356 If (tdriver = "(Auto Detect)") Then 357 Let tdriver = "" 358 End If 359 Let tcompress = cbTargetCompression.Text 360 If (tcompress = "(None)") Then 361 Let tcompress = "" 362 End If 363 364 Set source = Lib.open(cbSourceFilename.Text, driver, compress) 365 Set target = Lib.Create(cbTargetFilename.Text, tdriver, tcompress) 366 source.retries = Val(tbRetries.Text) 367 target.retries = Val(tbRetries.Text) 368 369 If cbFormat.Text = "(Auto Detect)" Then 370 Set geom = source.get_geometry() 371 Else 372 For n = 0 To Lib.stdformat_count - 1 373 Set geom2 = Lib.stdformat(n, name, (desc)) 374 If (cbFormat.Text = name + ":" + desc) Then 375 Set geom = geom2 376 End If 377 Next n 378 End If 379 For cylinder = 0 To geom.cylinders - 1 380 For head = 0 To geom.heads - 1 381 Call target.apform(geom, cylinder, head, 229) 382 For sector = 0 To geom.sectors - 1 383 lblProgress.Caption = "Cylinder " + Str(cylinder) + " Head " + Str(head) + " Sector " + Str(sector + geom.secbase) 384 buf = source.pread(geom, cylinder, head, sector + geom.secbase) 385 Call target.pwrite(geom, buf, cylinder, head, sector + geom.secbase) 386 Next sector 387 Next head 388 Next cylinder 389End Sub 390 391 392Private Sub btnDskForm_Click() 393 Dim Lib As LIBDSK.Library 394 Dim target As LIBDSK.Disk 395 Dim geom As LIBDSK.Geometry 396 Dim geom2 As LIBDSK.Geometry 397 Set Lib = New LIBDSK.Library 398 Lib.reporter = Me 399 400 Let tdriver = cbTargetDriver.Text 401 If (tdriver = "(Auto Detect)") Then 402 Let tdriver = "" 403 End If 404 Let tcompress = cbTargetCompression.Text 405 If (tcompress = "(None)") Then 406 Let tcompress = "" 407 End If 408 409 Set target = Lib.Create(cbTargetFilename.Text, tdriver, tcompress) 410 target.retries = Val(tbRetries.Text) 411 412 If cbFormat.Text = "(Auto Detect)" Then 413 Set geom = source.get_geometry() 414 Else 415 For n = 0 To Lib.stdformat_count - 1 416 Set geom2 = Lib.stdformat(n, name, (desc)) 417 If (cbFormat.Text = name + ":" + desc) Then 418 Set geom = geom2 419 End If 420 Next n 421 End If 422 For cylinder = 0 To geom.cylinders - 1 423 For head = 0 To geom.heads - 1 424 Call target.apform(geom, cylinder, head, 229) 425 Next head 426 Next cylinder 427 ' Real Dskform would now write the boot sector, but we don't bother 428End Sub 429 430 431 432 433Private Sub btnSourceBrowse_Click() 434 Dim cd As MSComDlg.CommonDialog 435 436 Set cd = New MSComDlg.CommonDialog 437 cd.FileName = cbSourceFilename.Text 438 cd.MaxFileSize = 2048 ' Set as appropriate 439 cd.Flags = cdlOFNExplorer 440 Call cd.ShowOpen 441 cbSourceFilename.Text = cd.FileName 442End Sub 443 444Private Sub btnTargetBrowse_Click() 445 Dim cd As MSComDlg.CommonDialog 446 447 Set cd = New MSComDlg.CommonDialog 448 cd.FileName = cbSourceFilename.Text 449 cd.MaxFileSize = 2048 ' Set as appropriate 450 cd.Flags = cdlOFNExplorer 451 Call cd.ShowOpen 452 cbSourceFilename.Text = cd.FileName 453 454End Sub 455 456' 457' Initialise the lists of drive types, compression types and formats. 458' 459Private Sub Form_Load() 460 Dim Lib As LIBDSK.Library 461 Set Lib = New LIBDSK.Library 462 Dim s As String 463 Dim name As String 464 Dim desc As String 465 466 cbSourceFilename.AddItem ("A:") 467 cbSourceFilename.AddItem ("B:") 468 cbTargetFilename.AddItem ("A:") 469 cbTargetFilename.AddItem ("B:") 470 471 cbDriver.AddItem ("(Auto Detect)") 472 cbCompression.AddItem ("(Auto Detect)") 473 cbTargetCompression.AddItem ("(None)") 474 Let n = 0 475 While Lib.type_enum(n, s) <> False 476 cbDriver.AddItem (s) 477 cbTargetDriver.AddItem (s) 478 n = n + 1 479 Wend 480 Let n = 0 481 While Lib.comp_enum(n, s) <> False 482 cbCompression.AddItem (s) 483 cbTargetCompression.AddItem (s) 484 n = n + 1 485 Wend 486 cbDriver.ListIndex = 0 487 cbCompression.ListIndex = 0 488 cbTargetDriver.ListIndex = 0 489 cbTargetCompression.ListIndex = 0 490 491 cbFormat.AddItem ("(Auto Detect)") 492 For n = 0 To Lib.stdformat_count - 1 493 Call Lib.stdformat(n, name, desc) 494 cbFormat.AddItem (name + ":" + desc) 495 Next n 496 cbFormat.ListIndex = 0 497 Lib.reporter = Me 498End Sub 499 500 501