summaryrefslogtreecommitdiff
path: root/Examples
diff options
context:
space:
mode:
Diffstat (limited to 'Examples')
-rw-r--r--Examples/DskImg.HC24
1 files changed, 20 insertions, 4 deletions
diff --git a/Examples/DskImg.HC b/Examples/DskImg.HC
index 0d54654..5912302 100644
--- a/Examples/DskImg.HC
+++ b/Examples/DskImg.HC
@@ -9,19 +9,35 @@
U8 DskImg()
{
- U64 i;
// Replace W with the letter you mounted your floppy as.
CDrv *dv=Let2Drv('W');
CBlkDev *bd=dv->blkdev;
+ U8 *buf=NULL;
+ U64 cyl,blk=0,cyl_len=bd->heads*bd->spt;
// Open image file for writing
CFile *img = FOpen("Floppy.IMG.C","wc",dv->size);
- //Read every sector on the disk to the file
- BlkRead(dv,img,0,bd->max_blk);
+ // Allocate a buffer for the cylinders
+ buf=MAlloc(cyl_len*bd->blk_size)
- // Close the image file
+ xfer_blk:
+ // If we are past the last blk, stop.
+ if (blk>bd->max_blk) goto done;
+
+ //Read in the cylinder
+ BlkRead(dv,buf,blk,cyl_len);
+
+ // Write it to the file
+ FBlkWrite(img,buf,blk,cyl_len);
+
+ // Move to the next cylinder
+ blk+=cyl_len;
+
+ done:
+ // Close the image file and release the buffer
FClose(img);
+ Free(buf);
return 0;
}