blob: f0cb3a7f911a428d369edbf78a5086d270f452f0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
/*
Copyright (C) 2025-2026 Harley Travis <yoshi128k@gmail.com>.
This software (including source code) is licensed under the BSD Zero Clause
License. See the Copying.TXT file for details.
*/
// PURPOSE: Demonstration of floppy driver
// TO USE: #include this file at the cmd prompt or run it with F5.
U8 DskImg()
{
// 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);
// Allocate a buffer for the cylinders
buf=MAlloc(cyl_len*bd->blk_size)
xfer_cyl:
// 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;
goto xfer_cyl;
done:
// Close the image file and release the buffer
FClose(img);
Free(buf);
return 0;
}
DskImg;
|