summaryrefslogtreecommitdiff
path: root/DskImg.HC
diff options
context:
space:
mode:
authorHarley Travis <harleytravis123@outlook.com>2026-05-23 23:17:07 -0500
committerHarley Travis <harleytravis123@outlook.com>2026-05-23 23:17:07 -0500
commit04d039d43164f48f5266d32e783d11f166b6161c (patch)
tree24f6edf85ef87c5f9cb04860006e0962b7319bbb /DskImg.HC
Initial commit (TOSFloppy-2025-04-17.zip)2025-04-17
This is taken from the earliest Discord release of the TempleOS floppy disk driver, released on April 17, 2025.
Diffstat (limited to 'DskImg.HC')
-rw-r--r--DskImg.HC67
1 files changed, 67 insertions, 0 deletions
diff --git a/DskImg.HC b/DskImg.HC
new file mode 100644
index 0000000..077a986
--- /dev/null
+++ b/DskImg.HC
@@ -0,0 +1,67 @@
+#define CYLINDERS 80
+#define SECTORS 18
+#define BASE 0x03F0
+#define IMG_SIZE 1474560
+
+/*
+
+ Make sure IRQ6 is on and
+ pointed to the correct handler!
+
+*/
+
+U8 DskImg()
+{
+ U64 i;
+
+ // Open image file for writing
+ CFile *img = FOpen("Floppy.IMG","w",IMG_SIZE/BLK_SIZE);
+
+ // Initialize the controller
+ FDCReset(BASE);
+ Sleep(100);
+
+ /*
+
+ Loop through each sector,
+ reading each into the buffer,
+ then writing it into the file
+
+ */
+
+ for (i = 0; i < CYLINDERS; i++) {
+ "Track %d\n", i;
+ if (FDCSeek(BASE, i, 0)) {
+ FDCReset(BASE);
+ FClose(img);
+ return 1;
+ }
+ if (FDCSeek(BASE, i, 1)) {
+ FDCReset(BASE);
+ FClose(img);
+ return 1;
+ }
+ FDCReadMulti(BASE, i, 0, 1, 18);
+ FBlkWrite(img, &FDC_DMA, 36 * i, 36);
+ }
+
+ // Return to track 0
+ "Returning to track 0...\n";
+ if (FDCSeek(BASE, 0, 0)) {
+ FDCReset(BASE);
+ FClose(img);
+ return 1;
+ }
+ if (FDCSeek(BASE, 0, 1)) {
+ FDCReset(BASE);
+ FClose(img);
+ return 1;
+ }
+
+ // Close the image file
+ FClose(img);
+
+ return 0;
+}
+
+DskImg; \ No newline at end of file