X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=include%2Fdio.h;h=1ccc1ab7ce88ea8dc19d1e90758b934ac6f9281f;hb=0dc4f64cfef201788ef95fe6b3d510f9972ba4dd;hp=9ae64a6ab3c01b2581e9f2dd8358dee7da4d90bf;hpb=e9a67d0abd9097283c5f32cd7d1cf9519a78097b;p=cc65 diff --git a/include/dio.h b/include/dio.h index 9ae64a6ab..1ccc1ab7c 100644 --- a/include/dio.h +++ b/include/dio.h @@ -6,7 +6,7 @@ /* */ /* */ /* */ -/* (C) 2000 Christian Groessler */ +/* (C) 2005 Christian Groessler */ /* */ /* */ /* This software is provided 'as-is', without any expressed or implied */ @@ -28,12 +28,27 @@ /* */ /*****************************************************************************/ + + #ifndef _DIO_H #define _DIO_H -typedef unsigned char driveid_t; -typedef unsigned int sectnum_t; -typedef unsigned int sectsize_t; + + +/* Please note: All functions in this file will set _oserror *and* return its + * value. The only exception is dio_open, which will return NULL, but _oserror + * will be set. All function will also set _oserror in case of successful + * execution, effectively clearing it. + */ + + + +/*****************************************************************************/ +/* Data */ +/*****************************************************************************/ + + + typedef struct __dhandle_t *dhandle_t; typedef struct { @@ -43,46 +58,56 @@ typedef struct { } dio_phys_pos; -#ifdef __ATARI__ -#define dio_query_sectsize(x) ((_sectsize_t)128) -#else -#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 */ +/*****************************************************************************/ +/* Code */ +/*****************************************************************************/ -extern unsigned char __fastcall__ dio_close(dhandle_t handle); -/* close drive */ -extern unsigned char __fastcall__ dio_read(dhandle_t handle, - sectnum_t sect_num, - void *buffer); -/* read sector from drive to memory at */ -/* the number of bytes transferred depends on the sector size */ -extern unsigned char __fastcall__ dio_write(dhandle_t handle, - sectnum_t sect_num, - const void *buffer); -/* write memory at to sector on drive , no verify */ +unsigned __fastcall__ dio_query_sectsize (dhandle_t handle); +/* returns sector size */ + +unsigned __fastcall__ dio_query_sectcount (dhandle_t handle); +/* returns sector count */ + +dhandle_t __fastcall__ dio_open (unsigned char device); +/* open device for subsequent dio access */ + +unsigned char __fastcall__ dio_close (dhandle_t handle); +/* close device, returns oserror (0 for success) */ + +unsigned char __fastcall__ dio_read (dhandle_t handle, + unsigned sect_num, + void *buffer); +/* read sector from device to memory at */ /* 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 to sector on drive , verify after write */ +unsigned char __fastcall__ dio_write (dhandle_t handle, + unsigned sect_num, + const void *buffer); +/* write memory at to sector on device , no verify */ /* the number of bytes transferred depends on the sector size */ +/* returns oserror (0 for success) */ +unsigned char __fastcall__ dio_write_verify (dhandle_t handle, + unsigned sect_num, + const void *buffer); +/* write memory at to sector on device , verify after write */ +/* the number of bytes transferred depends on the sector size */ +/* returns oserror (0 for success) */ -extern unsigned char __fastcall__ dio_phys_to_log(dhandle_t handle, - const dio_phys_pos *physpos, /* input */ - sectnum_t *sectnum); /* output */ +unsigned char __fastcall__ dio_phys_to_log (dhandle_t handle, + const dio_phys_pos *physpos, /* input */ + unsigned *sectnum); /* output */ /* convert physical sector address (head/track/sector) to logical sector number */ +/* returns oserror (0 for success) */ -extern unsigned char __fastcall__ dio_log_to_phys(dhandle_t handle, - const sectnum_t *sectnum, /* input */ - dio_phys_pos *physpos); /* output */ +unsigned char __fastcall__ dio_log_to_phys (dhandle_t handle, + const unsigned *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 */