X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=include%2Fdio.h;h=4201728cc9812045688c9de106ceaf966e518e4a;hb=2eac69a94361323bf7556d2cdde8f61c85c5ef99;hp=284eb0addf677766a9cc38a43ab0c7e02c9506eb;hpb=e40995c8899d2a502538c55105c4d5493a213f39;p=cc65 diff --git a/include/dio.h b/include/dio.h index 284eb0add..4201728cc 100644 --- a/include/dio.h +++ b/include/dio.h @@ -1,12 +1,12 @@ /*****************************************************************************/ /* */ -/* dio.h */ +/* dio.h */ /* */ -/* Low-Level diskette I/O functions */ +/* Low-Level diskette I/O functions */ /* */ /* */ /* */ -/* (C) 2000 Christian Groessler */ +/* (C) 2005 Christian Groessler */ /* */ /* */ /* This software is provided 'as-is', without any expressed or implied */ @@ -28,32 +28,86 @@ /* */ /*****************************************************************************/ + + #ifndef _DIO_H #define _DIO_H -typedef unsigned char _driveid_t; -typedef unsigned int _sectnum_t; -#ifdef __ATARI__ -#define _dio_query_sectsize(x) ((unsigned int)128) -#else -#define _dio_query_sectsize(x) ((unsigned int)256) -#endif +/* 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 { + unsigned char head; + unsigned track; + unsigned sector; +} dio_phys_pos; + + + +/*****************************************************************************/ +/* Code */ +/*****************************************************************************/ + + + +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_setup (_driveid_t drive_id); -extern unsigned char __fastcall__ _dio_finish (_driveid_t drive_id); +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) */ -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, void *buffer); -extern unsigned char __fastcall__ _dio_write_verify(_driveid_t drive_id, _sectnum_t sect_num, void *buffer); +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) */ +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 _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); +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 */