X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=device_win32.c;h=1829443242c47233973a24a96e5dbb521d994e69;hb=b1e873c5b2f6376bb39ff0fda1464cbbacbae5f7;hp=b8aef9b3e584d0eb98f96de5910a07ab766ecd61;hpb=669a947da532682fcdb01a4fcbb0d9418206bcd0;p=debian%2Fcpmtools diff --git a/device_win32.c b/device_win32.c index b8aef9b..1829443 100644 --- a/device_win32.c +++ b/device_win32.c @@ -2,8 +2,8 @@ #include "config.h" #include -#include #include +#include #include #include "cpmdir.h" @@ -385,18 +385,23 @@ const char *Device_open(struct Device *sb, const char *filename, int mode, const } /*}}}*/ /* Device_setGeometry -- Set disk geometry */ /*{{{*/ -void Device_setGeometry(struct Device *this, int secLength, int sectrk, int tracks) +const char * Device_setGeometry(struct Device *this, int secLength, int sectrk, int tracks, off_t offset, const char *libdskGeometry) { int n; this->secLength=secLength; this->sectrk=sectrk; this->tracks=tracks; + // Bill Buckels - add this->offset + this->offset=offset; + + + // Bill Buckels - not sure what to do here if (this->drvtype == CPMDRV_WIN95) { DRIVEPARAMS drvp; memset(&drvp, 0, sizeof(drvp)); - if (GetDriveParams( this->hdisk, this->fd, &drvp )) return; + if (GetDriveParams( this->hdisk, this->fd, &drvp )) return "GetDriveParams failed"; drvp.bytespersector = secLength; drvp.sectorspertrack = sectrk; @@ -443,6 +448,7 @@ void Device_setGeometry(struct Device *this, int secLength, int sectrk, int trac */ SetDriveParams( this->hdisk, this->fd, &drvp ); } + return NULL; } /*}}}*/ /* Device_close -- Close an image file */ /*{{{*/ @@ -484,7 +490,8 @@ const char *Device_readSector(const struct Device *drive, int track, int sector, LPVOID iobuffer; DWORD bytesread; - if (SetFilePointer(drive->hdisk, offset, NULL, FILE_BEGIN) == INVALID_FILE_SIZE) + // Bill Buckels - add drive->offset + if (SetFilePointer(drive->hdisk, offset+drive->offset, NULL, FILE_BEGIN) == INVALID_FILE_SIZE) { return strwin32error(); } @@ -511,6 +518,7 @@ const char *Device_readSector(const struct Device *drive, int track, int sector, return NULL; } + // Bill Buckels - not sure what to do here if (drive->drvtype == CPMDRV_WIN95) { DIOC_REGISTERS reg; @@ -552,7 +560,8 @@ const char *Device_readSector(const struct Device *drive, int track, int sector, return 0; } - if (lseek(drive->fd,offset,SEEK_SET)==-1) + // Bill Buckels - add drive->offset + if (lseek(drive->fd,offset+drive->offset,SEEK_SET)==-1) { return strerror(errno); } @@ -585,7 +594,8 @@ const char *Device_writeSector(const struct Device *drive, int track, int sector LPVOID iobuffer; DWORD byteswritten; - if (SetFilePointer(drive->hdisk, offset, NULL, FILE_BEGIN) == INVALID_FILE_SIZE) + // Bill Buckels - add drive->offset + if (SetFilePointer(drive->hdisk, offset+drive->offset, NULL, FILE_BEGIN) == INVALID_FILE_SIZE) { return strwin32error(); } @@ -607,6 +617,7 @@ const char *Device_writeSector(const struct Device *drive, int track, int sector return NULL; } + // Bill Buckels - not sure what to do here if (drive->drvtype == CPMDRV_WIN95) { DIOC_REGISTERS reg; @@ -648,7 +659,8 @@ const char *Device_writeSector(const struct Device *drive, int track, int sector return NULL; } - if (lseek(drive->fd,offset, SEEK_SET)==-1) + // Bill Buckels - add drive->offset + if (lseek(drive->fd,offset+drive->offset, SEEK_SET)==-1) { return strerror(errno); }