Skip to content

Commit

Permalink
Merge pull request #3 from RobSmithDev/1.0.2
Browse files Browse the repository at this point in the history
1.0.2
  • Loading branch information
RobSmithDev authored Aug 7, 2024
2 parents 48ff9db + 88bd68a commit eb2703b
Show file tree
Hide file tree
Showing 48 changed files with 2,826 additions and 319 deletions.
32 changes: 20 additions & 12 deletions ADFlib/src/adf_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ static struct AdfDevice *
}

if ( strncmp ( (char *) &rdsk, "RDSK", 4 ) == 0 ) {
rc = adfReadRDSKblock ( dev, &rdsk );
rc = adfReadRDSKblock ( dev, 0, &rdsk );
if ( rc == ADF_RC_OK ) {
/* rigid block loaded -> check geometry */
//if ( ! adfDevIsRDSKGeometryValid_ ( dev, &rdsk ) ) {
Expand Down Expand Up @@ -286,18 +286,26 @@ ADF_RETCODE adfDevMount ( struct AdfDevice * const dev )
case ADF_DEVTYPE_HARDDISK:
case ADF_DEVTYPE_HARDFILE: {
uint8_t buf[512];
rc = adfDevReadBlock ( dev, 0, 512, buf );
if ( rc != ADF_RC_OK ) {
adfEnv.eFct ( "adfMountDev : reading block 0 of %s failed", dev->name );
return rc;
// RDSK can be in the first 64 blocks
bool mounted = false;
for (uint32_t offset = 0; offset <= 63; offset++) {
rc = adfDevReadBlock(dev, offset, 512, buf);
if (rc != ADF_RC_OK) {
adfEnv.eFct("adfMountDev : reading block %i of %s failed", offset, dev->name);
return rc;
}
if (strncmp("RDSK", (char*)buf, 4) == 0) {
dev->devType = ADF_DEVTYPE_HARDDISK;
rc = adfMountHd(dev, offset);
if (rc == ADF_RC_OK) {
mounted = true;
break;
}
}
}

if ( strncmp ( "RDSK", (char *) buf, 4 ) == 0 ) {
dev->devType = ADF_DEVTYPE_HARDDISK;
rc = adfMountHd ( dev );
} else {
if (!mounted) {
dev->devType = ADF_DEVTYPE_HARDFILE;
rc = adfMountHdFile ( dev );
rc = adfMountHdFile(dev);
}

if ( rc != ADF_RC_OK )
Expand Down Expand Up @@ -382,7 +390,7 @@ static ADF_RETCODE adfDevSetCalculatedGeometry_ ( struct AdfDevice * const dev )
dev->heads = 2;
dev->sectors = 22;
dev->cylinders = dev->size / ( dev->heads * dev->sectors * 512 );
if ( dev->cylinders != 80 ) {
if (dev->cylinders < 80 || dev->cylinders > 83) {
adfEnv.eFct ( "adfDevSetCalculatedGeometry_: invalid size %u", dev->size );
return ADF_RC_ERROR;
}
Expand Down
7 changes: 4 additions & 3 deletions ADFlib/src/adf_dev_hd.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ ADF_RETCODE adfMountHdFile ( struct AdfDevice * const dev )
*
* fills geometry fields and volumes list (dev->nVol and dev->volList[])
*/
ADF_RETCODE adfMountHd ( struct AdfDevice * const dev )
ADF_RETCODE adfMountHd ( struct AdfDevice * const dev, const int32_t rdskBlock )
{
struct AdfRDSKblock rdsk;
struct AdfPARTblock part;
Expand All @@ -181,7 +181,7 @@ ADF_RETCODE adfMountHd ( struct AdfDevice * const dev )
struct AdfVolume * vol;
unsigned len;

ADF_RETCODE rc = adfReadRDSKblock ( dev, &rdsk );
ADF_RETCODE rc = adfReadRDSKblock ( dev, rdskBlock , &rdsk );
if ( rc != ADF_RC_OK )
return rc;

Expand Down Expand Up @@ -505,11 +505,12 @@ ADF_RETCODE adfCreateHdFile ( struct AdfDevice * const dev,
*
*/
ADF_RETCODE adfReadRDSKblock ( struct AdfDevice * const dev,
const int32_t rdskBlockIndex,
struct AdfRDSKblock * const blk )
{
uint8_t buf[256];

ADF_RETCODE rc = adfDevReadBlock ( dev, 0, 256, buf );
ADF_RETCODE rc = adfDevReadBlock ( dev, rdskBlockIndex, 256, buf );
if ( rc != ADF_RC_OK )
return rc;

Expand Down
3 changes: 2 additions & 1 deletion ADFlib/src/adf_dev_hd.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include "adf_blk_hd.h"
#include "adf_prefix.h"

ADF_RETCODE adfMountHd ( struct AdfDevice * const dev );
ADF_RETCODE adfMountHd ( struct AdfDevice * const dev, const int32_t rdskBlock);
ADF_RETCODE adfMountHdFile ( struct AdfDevice * const dev );

ADF_RETCODE adfCreateHdHeader ( struct AdfDevice * const dev,
Expand All @@ -50,6 +50,7 @@ ADF_PREFIX ADF_RETCODE adfCreateHdFile ( struct AdfDevice * const dev,
const uint8_t volType );

ADF_PREFIX ADF_RETCODE adfReadRDSKblock ( struct AdfDevice * const dev,
const int32_t rdskBlockIndex,
struct AdfRDSKblock * const blk );

ADF_RETCODE adfWriteRDSKblock ( struct AdfDevice * const dev,
Expand Down
2 changes: 1 addition & 1 deletion ADFlib/src/adf_prefix.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@

#ifndef ADF_PREFIX_H
#define ADF_PREFIX_H

//#ifdef WIN32DLL
//#ifdef _WIN32
#ifdef BUILD_DLL


/* define declaration prefix for exporting symbols compiling a DLL library,
and importing when compiling a client code
Expand Down
2 changes: 1 addition & 1 deletion ADFlib/src/adf_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void dumpBlock ( const uint8_t * const buf );


#ifndef HAVE_STRNDUP
#pragma message "Using the custom strndup()"
//#pragma message "Using the custom strndup()"
char * strndup ( const char * const s, size_t n );
#endif

Expand Down
15 changes: 10 additions & 5 deletions PFS3lib/pfs3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class PFS3 : public IPFS3 {
const std::function<bool(uint32_t physicalSector, uint32_t readSize, void* data)> m_readSector;
const std::function<bool(uint32_t physicalSector, uint32_t readSize, const void* data)> m_writeSector;
const std::function<void(const std::string& message)> m_pfsError;
bool m_readOnly;

globaldata* g = nullptr;

Expand All @@ -35,7 +36,8 @@ class PFS3 : public IPFS3 {
PFS3(const struct DriveInfo& drive, const struct PartitionInfo& partition,
const std::function<bool(uint32_t physicalSector, uint32_t readSize, void* data)> readSector,
const std::function<bool(uint32_t physicalSector, uint32_t readSize, const void* data)> writeSector,
const std::function<void(const std::string& message)> pfsError);
const std::function<void(const std::string& message)> pfsError,
const bool readOnly);
~PFS3();

// Is it available?
Expand Down Expand Up @@ -100,8 +102,8 @@ class PFS3 : public IPFS3 {
virtual Error Dir(const std::string& path, std::function<void(const FileInformation& fileDir)> onFileDir) override;
};

IPFS3* IPFS3::createInstance(const struct DriveInfo& drive, const struct PartitionInfo& partition, const std::function<bool(uint32_t physicalSector, uint32_t readSize, void* data)> readSector, const std::function<bool(uint32_t physicalSector, uint32_t readSize, const void* data)> writeSector, const std::function<void(const std::string& message)> pfsError) {
return new PFS3(drive, partition, readSector, writeSector, pfsError);
IPFS3* IPFS3::createInstance(const struct DriveInfo& drive, const struct PartitionInfo& partition, const std::function<bool(uint32_t physicalSector, uint32_t readSize, void* data)> readSector, const std::function<bool(uint32_t physicalSector, uint32_t readSize, const void* data)> writeSector, const std::function<void(const std::string& message)> pfsError, const bool readOnly) {
return new PFS3(drive, partition, readSector, writeSector, pfsError, readOnly);
}


Expand Down Expand Up @@ -156,14 +158,16 @@ LONG _NormalErrorMsg(CONST_STRPTR melding, APTR arg, ULONG notargets, globaldata
PFS3::PFS3(const struct PFS3::DriveInfo& drive, const struct PartitionInfo& partition,
const std::function<bool(uint32_t physicalSector, uint32_t readSize, void* data) > readSector,
const std::function<bool(uint32_t physicalSector, uint32_t readSize, const void* data) > writeSector,
const std::function<void(const std::string& message)> pfsError
const std::function<void(const std::string& message)> pfsError,
const bool readOnly
)
: m_readSector(readSector), m_writeSector(writeSector), m_pfsError(pfsError), IPFS3() {
: m_readSector(readSector), m_writeSector(writeSector), m_pfsError(pfsError), IPFS3(), m_readOnly(readOnly) {

g = (globaldata*)malloc(sizeof(globaldata));
if (!g) return;
memset(g, 0, sizeof(globaldata));

g->softprotect = readOnly ? 1 : 0;
g->dosenvec.de_SizeBlock = partition.blockSize;
g->dosenvec.de_SectorPerBlock = partition.sectorsPerBlock;
g->dosenvec.de_BlocksPerTrack = partition.blocksPerTrack;
Expand All @@ -189,6 +193,7 @@ PFS3::PFS3(const struct PFS3::DriveInfo& drive, const struct PartitionInfo& part
};

g->writeSector = [this](uint32_t logicalSector, void* data) {
if (m_readOnly) return false;
// TODO: Handle g->blocksize not being 512
if (!m_writeSector) return false;
return m_writeSector(g->firstblocknative + logicalSector, g->blocksize, data);
Expand Down
3 changes: 2 additions & 1 deletion PFS3lib/pfs3.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ class EXPORT IPFS3 {
static IPFS3* createInstance(const struct DriveInfo& drive, const struct PartitionInfo& partition,
const std::function<bool(uint32_t physicalSector, uint32_t readSize, void* data)> readSector,
const std::function<bool(uint32_t physicalSector, uint32_t readSize, const void* data)> writeSector,
const std::function<void(const std::string& message)> pfsError);
const std::function<void(const std::string& message)> pfsError,
const bool readOnly);

virtual ~IPFS3() {};

Expand Down
25 changes: 14 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,26 @@
A Windows package to use Floppy Disk Images Files & Real Floppy Disks in Windows, directly.

## Why?
Most of the USB floppy drives are terrible. And modifying a drive for DrawBridge removes the IBM/PC floppy disk support in Windows. Plus I was getting annoyed having to boot WinUAE just to copy a file to an ADF (or disk). So I built this - And all the silly playground arguments from childhood now behind us I gave a little love to the Atari ST too (untested, I don't have one!)...
I wanted to be able to access my Amiga and other systems floppy disks without having to boot an emulator. I wanted to be able to open a disk image file (like ADF, IMG etc) in Windows in the easiest way possible, as well as be able to use a real floppy drive too and see whats on it.
So I decided to build this - which allows you to view and edit the contents of real disks (floppy and hard drive) and disk image files directly from Windows Explorer, and yes, you can even read non-PC floppy and hard disks in real time too (hardware required for floppy disks).
Checkout https://robsmithdev.co.uk/diskflashback for more details!

## Features
- Mount ADF, DMS*, IMG, IMA, ST, MSA*, HDA, HDF and SCP* disk and hard drive files as virtual drives (* are read only)
- Supports AmigaDOS OFS/FFS DD & HD Disks
- Mount ADF, DMS*, IMG, IMA, ST, MSA*, HDA, HDF, DSK (MSX) and SCP* files as virtual drives (* read only)
- Supports AmigaDOS OFS/FFS/PFS File Systems for Floppy & Hard Disks
- Supports IBM/PC FAT12/16 DD 720k & HD 1.44Mb Disks
- Supports Atari ST FAT12/16 GemDOS Single and Double Sided normal & extended Disks
- Supports Dual Format Amiga/Atari floppy disks and mounts them as two drives! (read only)
- Use your DrawBridge, Greaseweazle or SupercardPRO board as a real floppy drive with direct access to files
- Can create new disk images of any of the above formats.
- Rip real floppy disks to the above formats
- Supports MSX FAT12 File system (some characters will be incorrect)
- Supports Dual/Tripple Format Amiga/Atari floppy disks and mounts them as two drives! (read only)
- Mount your DrawBridge, Greaseweazle or SupercardPro as a real floppy drive in Windows
- Mount your real Amiga Hard Disks/Memory Cards as drives
- Create blank disk images for the above formats.
- Rip real floppy disks to file (sector based files only)
- Write disk images to real floppy disks
- Install boot blocks on Amiga floppy disks
- Optionally silently swap file extensions (eg: mod.thismusic to thismusic.mod)


- Install boot blocks on Amiga disks
- Format floppy disks in a range of formats
- Optionally silently swap Amiga file extensions (eg: mod.thismusic to thismusic.mod)
- Provides a simple floppy drive head cleaner function

## How does it work?
DiskFlashback is powered by:
Expand Down
31 changes: 29 additions & 2 deletions Release Notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,35 @@ DiskFlashback Release Notes
---------------------------
https://robsmithdev.co.uk/diskflashback

1.0.1.0
Fixed disabling "auto-detect com port" beign ignored
1.0.2
Sped up the Greaseweazle track reading speed by almost double
Sped up the Supercard PRO track reading speed by almost double
Small speed up for DrawBridge reading too!
Sped up disk writing as well!
Added special message for people just trying to run the DiskFlashback EXE and wondering why it doesn't do anything
Added new "Clean Drive Heads" option for real floppy drives (cleaning disk required)
Re-arranged all physical drive related commands into its own menu
Added option to toggle the auto-starting up the system tray icon with Windows
Changed how new versions of the application are detected to hopefully get around some previous false positives
Mount physical Amiga HD/Memory Card disks as drive letters (OFS/FFS/PFS only)
Can now detect Amiga hard disk partitions when RDSK block is not on the first block (can be upto 64 blocks in)
Better / quicker cooldown if disk is removed from physical drive while its being read
Added support for DSK (MSX) files as they're basically FAT12 PC disks
Fixed a bug with some DMS files where the total number of cylinders was incorrectly read
Fixed potential re-entry bug from aborting some operations and turning off the drive motor
Fixed issues with SuperCard PRO board not seeking to the correct track [FloppyBridge]
Fixed an issue where some SCP files wouldn't load at all
Fixed some issues with some dual-format disk images not showing both parts
Fixed issues with Tri-format disks (they're actually dual-format really)
Fixed an issue with dual-format disks where number of heads was incorrectly used for PC/Atari side
Fixed issue where re-reading bad Amiga sectors didn't work properly
Fixed a strange seek issue when ejecting real floppy disks
Fixed issue with some dialogs disappearing behind explorer after message was shown
Fixed an issue where changing file attributes (Amiga) caused the Readable/Delete attributes to become unset
EXEs etc are now digitally signed

1.0.1
Fixed disabling "auto-detect com port" being ignored
Better support for hard disk image files larger than 4G (some partitions got ignored before)
Upgraded to use the new ADFLib v0.9
Changed error handling when reading from disks to include the Always Ignore option
Expand Down
Loading

0 comments on commit eb2703b

Please sign in to comment.