diff options
| author | Harley Travis <harleytravis123@outlook.com> | 2026-07-04 17:25:12 -0500 |
|---|---|---|
| committer | Harley Travis <harleytravis123@outlook.com> | 2026-07-04 17:25:12 -0500 |
| commit | 3787fcdb5e4c5eef790fa29887e6a68c7a511729 (patch) | |
| tree | 60356848699136e45217da99fafdda4ef841dcf5 /Examples | |
| parent | 379a01f050ade2a94c1688ecd7c23c4efd046768 (diff) | |
| download | templeos-floppy-driver-3787fcdb5e4c5eef790fa29887e6a68c7a511729.tar.gz | |
Overhaul DskImg to use a U8 buf.
Diffstat (limited to 'Examples')
| -rw-r--r-- | Examples/DskImg.HC | 24 |
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; } |
