]> git.sur5r.net Git - cc65/blob - include/dio.h
Fixed _textcolor definition.
[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 <chris@groessler.org>                        */
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 /* Please note: All functions in this file will set _oserror *and* return its
39 ** value. The only exception is dio_open, which will return NULL, but _oserror
40 ** will be set. All function will also set _oserror in case of successful
41 ** execution, effectively clearing it.
42 */
43
44
45
46 /*****************************************************************************/
47 /*                                   Data                                    */
48 /*****************************************************************************/
49
50
51
52 typedef struct __dhandle_t *dhandle_t;
53
54 typedef struct {
55   unsigned char  head;
56   unsigned       track;
57   unsigned       sector;
58 } dio_phys_pos;
59
60
61
62 /*****************************************************************************/
63 /*                                   Code                                    */
64 /*****************************************************************************/
65
66
67
68 unsigned __fastcall__ dio_query_sectsize (dhandle_t handle);
69 /* returns sector size */
70
71 unsigned __fastcall__ dio_query_sectcount (dhandle_t handle);
72 /* returns sector count */
73
74 dhandle_t __fastcall__ dio_open (unsigned char device);
75 /* open device for subsequent dio access */
76
77 unsigned char __fastcall__ dio_close (dhandle_t handle);
78 /* close device, returns oserror (0 for success) */
79
80 unsigned char __fastcall__ dio_read (dhandle_t handle,
81                                      unsigned sect_num,
82                                      void *buffer);
83 /* read sector <sect_num> from device <handle> to memory at <buffer> */
84 /* the number of bytes transferred depends on the sector size */
85 /* returns oserror (0 for success) */
86
87 unsigned char __fastcall__ dio_write (dhandle_t handle,
88                                       unsigned sect_num,
89                                       const void *buffer);
90 /* write memory at <buffer> to sector <sect_num> on device <handle>, no verify */
91 /* the number of bytes transferred depends on the sector size */
92 /* returns oserror (0 for success) */
93
94 unsigned char __fastcall__ dio_write_verify (dhandle_t handle,
95                                              unsigned sect_num,
96                                              const void *buffer);
97 /* write memory at <buffer> to sector <sect_num> on device <handle>, verify after write */
98 /* the number of bytes transferred depends on the sector size */
99 /* returns oserror (0 for success) */
100
101 unsigned char __fastcall__ dio_phys_to_log (dhandle_t handle,
102                                             const dio_phys_pos *physpos, /* input */
103                                             unsigned *sectnum);          /* output */
104 /* convert physical sector address (head/track/sector) to logical sector number */
105 /* returns oserror (0 for success) */
106
107 unsigned char __fastcall__ dio_log_to_phys (dhandle_t handle,
108                                             const unsigned *sectnum, /* input */
109                                             dio_phys_pos *physpos);  /* output */
110 /* convert logical sector number to physical sector address (head/track/sector) */
111 /* returns oserror (0 for success) */
112
113 #endif /* #ifndef _DIO_H */