]> git.sur5r.net Git - cc65/blobdiff - include/dio.h
Fixed a bug
[cc65] / include / dio.h
index 3153094ee5528ccd8982f0e2d1bb189444c5c20e..e6fca58fe476432b56a4c2c814e2da1aa9003850 100644 (file)
@@ -1,8 +1,8 @@
 /*****************************************************************************/
 /*                                                                           */
-/*                                  dio.h                                   */
+/*                                   dio.h                                   */
 /*                                                                           */
-/*                      Low-Level diskette I/O functions                    */
+/*                       Low-Level diskette I/O functions                    */
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
 #ifndef _DIO_H
 #define _DIO_H
 
-typedef unsigned char _driveid_t;
-typedef unsigned int  _sectnum_t;
-typedef unsigned int  _sectsize_t;
+typedef unsigned char       driveid_t;
+typedef unsigned int        sectnum_t;
+typedef unsigned int        sectsize_t;
+typedef struct __dhandle_t *dhandle_t;
+
+typedef struct {
+  unsigned char  head;
+  unsigned       track;
+  unsigned       sector;
+} dio_phys_pos;
 
 
 #ifdef __ATARI__
-#define _dio_query_sectsize(x) ((_sectsize_t)128)
+#define dio_query_sectsize(x) ((_sectsize_t)128)
 #else
-#define _dio_query_sectsize(x) ((_sectsize_t)256)
+#define dio_query_sectsize(x) ((_sectsize_t)256)
 #endif
+/* queries sector size, currently hardcoded */
+
+extern dhandle_t     __fastcall__ dio_open(driveid_t drive_id);
+/* open drive for subsequent dio access */
+
+extern unsigned char __fastcall__ dio_close(dhandle_t handle);
+/* close drive, returns oserror (0 for success) */
+
+extern unsigned char __fastcall__ dio_read(dhandle_t handle,
+                                           sectnum_t sect_num,
+                                           void *buffer);
+/* read sector <sect_num> from drive <handle> to memory at <buffer> */
+/* the number of bytes transferred depends on the sector size */
+/* returns oserror (0 for success) */
+
+extern unsigned char __fastcall__ dio_write(dhandle_t handle,
+                                            sectnum_t sect_num,
+                                            const void *buffer);
+/* write memory at <buffer> to sector <sect_num> on drive <handle>, no verify */
+/* the number of bytes transferred depends on the sector size */
+/* returns oserror (0 for success) */
+
+extern unsigned char __fastcall__ dio_write_verify(dhandle_t handle,
+                                                   sectnum_t sect_num,
+                                                   const void *buffer);
+/* write memory at <buffer> to sector <sect_num> on drive <handle>, verify after write */
+/* the number of bytes transferred depends on the sector size */
+/* returns oserror (0 for success) */
 
-extern unsigned char __fastcall__ _dio_open  (_driveid_t drive_id);
-extern unsigned char __fastcall__ _dio_close (_driveid_t drive_id);
-extern unsigned char __fastcall__ _dio_format(_driveid_t drive_id,
-                                              unsigned int format);
-extern unsigned char __fastcall__ _dio_read(_driveid_t drive_id,
-                                            _sectnum_t sect_num,
-                                            void *buffer);
-extern unsigned char __fastcall__ _dio_write(_driveid_t drive_id,
-                                             _sectnum_t sect_num,
-                                             const void *buffer);
-extern unsigned char __fastcall__ _dio_write_verify(_driveid_t drive_id,
-                                                    _sectnum_t sect_num,
-                                                    const void *buffer);
 
+extern unsigned char __fastcall__ dio_phys_to_log(dhandle_t handle,
+                                                  const dio_phys_pos *physpos, /* input */
+                                                  sectnum_t *sectnum);        /* output */
+/* convert physical sector address (head/track/sector) to logical sector number */
+/* returns oserror (0 for success) */
 
-extern _sectnum_t __fastcall__ _dio_chs_to_snum(unsigned int cyl,
-                                                unsigned int head,
-                                                unsigned int sector);
-extern void       __fastcall__ _dio_snum_to_chs(_sectnum_t sect_num,
-                                                unsigned int *cyl,
-                                                unsigned int *head,
-                                                unsigned int *sector);
+extern unsigned char __fastcall__ dio_log_to_phys(dhandle_t handle,
+                                                  const sectnum_t *sectnum,    /* input */
+                                                  dio_phys_pos *physpos);     /* output */
+/* convert logical sector number to physical sector address (head/track/sector) */
+/* returns oserror (0 for success) */
 
 #endif /* #ifndef _DIO_H */