X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Ffloppy.cpp;h=b2586e83224dc97c3341b6fe42efdef1f1338391;hb=f36d026c7b8b398b88765ec5b67a3c767fe5fbad;hp=b014af08bb4fe515344948b8e99fc8d1913a9c35;hpb=aec4f863c3fb9a6b6db7e9f0887f360cbdee35cb;p=apple2 diff --git a/src/floppy.cpp b/src/floppy.cpp old mode 100755 new mode 100644 index b014af0..b2586e8 --- a/src/floppy.cpp +++ b/src/floppy.cpp @@ -1,10 +1,10 @@ // // Apple 2 floppy disk support // -// by James L. Hammons +// by James Hammons // (c) 2005 Underground Software // -// JLH = James L. Hammons +// JLH = James Hammons // // WHO WHEN WHAT // --- ---------- ------------------------------------------------------------ @@ -118,6 +118,7 @@ bool FloppyDrive::LoadImage(const char * filename, uint8_t driveNum/*= 0*/) bool FloppyDrive::SaveImage(uint8_t driveNum/*= 0*/) { + // Various sanity checks... if (driveNum > 1) { WriteLog("FLOPPY: Attempted to save image to drive #%u!\n", driveNum); @@ -136,11 +137,13 @@ bool FloppyDrive::SaveImage(uint8_t driveNum/*= 0*/) return false; } + // Handle nybbylization, if necessary if (diskType[driveNum] == DT_NYBBLE) memcpy(disk[driveNum], nybblizedImage[driveNum], 232960); else DenybblizeImage(driveNum); + // Finally, write the damn image FILE * fp = fopen(imageName[driveNum], "wb"); if (fp == NULL) @@ -237,31 +240,41 @@ void FloppyDrive::DetectImageType(const char * filename, uint8_t driveNum) WriteLog("FLOPPY: Found extension [%s]...\n", ext); //Apparently .dsk can house either DOS order OR PRODOS order... !!! FIX !!! -//[DONE, see below why we don't need it] if (strcasecmp(ext, ".po") == 0) diskType[driveNum] = DT_PRODOS; else if ((strcasecmp(ext, ".do") == 0) || (strcasecmp(ext, ".dsk") == 0)) { + // We assume this, but check for a PRODOS fingerprint. Trust, but + // verify. ;-) diskType[driveNum] = DT_DOS33; -//WriteLog("Detected DOS 3.3 disk!\n"); -/* -This doesn't seem to be accurate... Maybe it's just a ProDOS disk in a DOS33 order... -That would seem to be the case--just because it's a ProDOS disk doesn't mean anything -WRT to the disk image itself. - // This could really be a ProDOS order disk with a .dsk extension, so let's see... - char fingerprint[3][4] = { - { 0x04, 0x00, 0x00, 0x00 }, // @ $500 - { 0x03, 0x00, 0x05, 0x00 }, // @ $700 - { 0x02, 0x00, 0x04, 0x00 } }; // @ $900 - - if ((strcmp((char *)(disk[driveNum] + 0x500), fingerprint[0]) == 0) - && (strcmp((char *)(disk[driveNum] + 0x700), fingerprint[1]) == 0) - && (strcmp((char *)(disk[driveNum] + 0x900), fingerprint[2]) == 0)) + + uint8_t fingerprint[4][4] = { + { 0x00, 0x00, 0x03, 0x00 }, // @ $400 + { 0x02, 0x00, 0x04, 0x00 }, // @ $600 + { 0x03, 0x00, 0x05, 0x00 }, // @ $800 + { 0x04, 0x00, 0x00, 0x00 } // @ $A00 + }; + + bool foundProdos = true; + + for(uint32_t i=0; i<4; i++) + { + for(uint32_t j=0; j<4; j++) + { + if (disk[driveNum][0x400 + (i * 0x200) + j] != fingerprint[i][j]) + { + foundProdos = false; + break; + } + } + } + + if (foundProdos) diskType[driveNum] = DT_PRODOS; -//*/ } // Actually, it just might matter WRT to nybblyzing/denybblyzing +// (and, it does... :-P) NybblizeImage(driveNum); } else if (diskSize[driveNum] == 143488)