]> git.sur5r.net Git - cc65/blob - include/dio.h
New function dio_query_sectcount and cosmetic changes
[cc65] / include / dio.h
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                   dio.h                                   */
4 /*                                                                           */
5 /*                       Low-Level diskette I/O functions                    */
6 /*                                                                           */
7 /*                                                                           */
8 /*                                                                           */
9 /* (C) 2005 Christian Groessler <cpg@aladdin.de>                             */
10 /*                                                                           */
11 /*                                                                           */
12 /* This software is provided 'as-is', without any expressed or implied       */
13 /* warranty.  In no event will the authors be held liable for any damages    */
14 /* arising from the use of this software.                                    */
15 /*                                                                           */
16 /* Permission is granted to anyone to use this software for any purpose,     */
17 /* including commercial applications, and to alter it and redistribute it    */
18 /* freely, subject to the following restrictions:                            */
19 /*                                                                           */
20 /* 1. The origin of this software must not be misrepresented; you must not   */
21 /*    claim that you wrote the original software. If you use this software   */
22 /*    in a product, an acknowledgment in the product documentation would be  */
23 /*    appreciated but is not required.                                       */
24 /* 2. Altered source versions must be plainly marked as such, and must not   */
25 /*    be misrepresented as being the original software.                      */
26 /* 3. This notice may not be removed or altered from any source              */
27 /*    distribution.                                                          */
28 /*                                                                           */
29 /*****************************************************************************/
30
31
32
33 #ifndef _DIO_H
34 #define _DIO_H
35
36
37
38 /*****************************************************************************/
39 /*                                   Data                                    */
40 /*****************************************************************************/
41
42
43
44 typedef unsigned char       driveid_t;
45 typedef unsigned int        sectnum_t;
46 typedef unsigned int        sectsize_t;
47 typedef struct __dhandle_t *dhandle_t;
48
49 typedef struct {
50   unsigned char  head;
51   unsigned       track;
52   unsigned       sector;
53 } dio_phys_pos;
54
55
56
57 /*****************************************************************************/
58 /*                                   Code                                    */
59 /*****************************************************************************/
60
61
62
63 sectsize_t __fastcall__ dio_query_sectsize(dhandle_t handle);
64 /* queries sector size, currently hardcoded */
65
66 sectnum_t __fastcall__ dio_query_sectcount(dhandle_t handle);
67 /* Return the sector count for a disk. */
68
69 dhandle_t __fastcall__ dio_open(driveid_t drive_id);
70 /* open drive for subsequent dio access */
71
72 unsigned char __fastcall__ dio_close(dhandle_t handle);
73 /* close drive, returns oserror (0 for success) */
74
75 unsigned char __fastcall__ dio_read(dhandle_t handle,
76                                     sectnum_t sect_num,
77                                     void *buffer);
78 /* read sector <sect_num> from drive <handle> to memory at <buffer> */
79 /* the number of bytes transferred depends on the sector size */
80 /* returns oserror (0 for success) */
81
82 unsigned char __fastcall__ dio_write(dhandle_t handle,
83                                      sectnum_t sect_num,
84                                      const void *buffer);
85 /* write memory at <buffer> to sector <sect_num> on drive <handle>, no verify */
86 /* the number of bytes transferred depends on the sector size */
87 /* returns oserror (0 for success) */
88
89 unsigned char __fastcall__ dio_write_verify(dhandle_t handle,
90                                             sectnum_t sect_num,
91                                             const void *buffer);
92 /* write memory at <buffer> to sector <sect_num> on drive <handle>, verify after write */
93 /* the number of bytes transferred depends on the sector size */
94 /* returns oserror (0 for success) */
95
96
97 unsigned char __fastcall__ dio_phys_to_log(dhandle_t handle,
98                                            const dio_phys_pos *physpos, /* input */
99                                            sectnum_t *sectnum);         /* output */
100 /* convert physical sector address (head/track/sector) to logical sector number */
101 /* returns oserror (0 for success) */
102
103 unsigned char __fastcall__ dio_log_to_phys(dhandle_t handle,
104                                            const sectnum_t *sectnum, /* input */
105                                            dio_phys_pos *physpos);   /* output */
106 /* convert logical sector number to physical sector address (head/track/sector) */
107 /* returns oserror (0 for success) */
108
109 #endif /* #ifndef _DIO_H */