From 3787fcdb5e4c5eef790fa29887e6a68c7a511729 Mon Sep 17 00:00:00 2001 From: Harley Travis Date: Sat, 4 Jul 2026 17:25:12 -0500 Subject: Overhaul DskImg to use a U8 buf. --- Examples/DskImg.HC | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'Examples') 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; } -- cgit v1.2.3