From d861f94fbec30b7018a7c71075fa667ef5ca139b Mon Sep 17 00:00:00 2001 From: Marcio T Date: Thu, 25 Nov 2021 20:40:16 -0700 Subject: [PATCH] Added detection of Jaz drives --- README.md | 1 - mac-cpp-source/Iomega Zip Tester.cpp | 6 ++-- mac-cpp-source/scsi/mac_scsi.cpp | 2 +- mac-cpp-source/tip/tip.cpp | 30 +++++++++++++++----- mac-cpp-source/tip/tip.h | 6 ++++ mac-cpp-source/tip/tip_aspi.cpp | 42 +++++++++++++++++++++++++--- mac-cpp-source/tip/tip_main.cpp | 2 +- mac-cpp-source/tip/tip_text.cpp | 4 +++ 8 files changed, 76 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 2a18e5f..07478b7 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,6 @@ It has been tested in on the following environments: What will not work or is missing: -* Support for JAZ drives is currently missing. * TIP will only do a read-pass and the write-tests have been disabled. * The functionality for operating with password or write protected disks is missing. * The partition recovery feature has been removed, since it is meant for PC disks. diff --git a/mac-cpp-source/Iomega Zip Tester.cpp b/mac-cpp-source/Iomega Zip Tester.cpp index 1ac4a9b..b69c10d 100644 --- a/mac-cpp-source/Iomega Zip Tester.cpp +++ b/mac-cpp-source/Iomega Zip Tester.cpp @@ -96,10 +96,10 @@ void scan_bus() { printf( " %hd: (Not installed)\n", id ); } else { printf( " %hd: ", id ); - printn( reply.prod, 16 ); - printf( " " ); printn( reply.vend, 8 ); - printf( " " ); + printf( ", " ); + printn( reply.prod, 16 ); + printf( ", " ); printn( reply.rvsn, 4 ); putchar( '\n' ); } diff --git a/mac-cpp-source/scsi/mac_scsi.cpp b/mac-cpp-source/scsi/mac_scsi.cpp index 6930ce0..1f77477 100644 --- a/mac-cpp-source/scsi/mac_scsi.cpp +++ b/mac-cpp-source/scsi/mac_scsi.cpp @@ -48,7 +48,7 @@ OSErr scsi_cmd(int id, void *cmd, size_t clen, void *buff, size_t siz, size_t cn if (err != noErr) {printf("SCSIGet Error: %d\n", err); return err;} err = SCSISelect(id); - if (err != noErr) {printf("SCSISelect Error: %d\n", err); return err;} + if (err != noErr) {/*printf("SCSISelect Error: %d\n", err);*/ return err;} /* Send the command to the SCSI device and perform the requested I/O */ err = SCSICmd( (Ptr) cmd, clen ); diff --git a/mac-cpp-source/tip/tip.cpp b/mac-cpp-source/tip/tip.cpp index 3049d0e..5273e4e 100644 --- a/mac-cpp-source/tip/tip.cpp +++ b/mac-cpp-source/tip/tip.cpp @@ -19,11 +19,24 @@ Rect TL_Sect = SET_RECT( 75, 154, 203, 170); Rect ES_Read = SET_RECT(346, 154, 409, 170); Rect SE_Rect = SET_RECT(222, 154, 255, 221); +/******************************************************************************* + * WinMain + * + * Startup the Windows program. + *******************************************************************************/ +void WinMain(int Device) { + CurrentDevice = Device; + // test for an Iomega device + EnumerateIomegaDevices(CurrentDevice); + // now startup the timer for real-time features + StartApplicationTimer(); +} + /******************************************************************************* * WndProc * * This is the system's main window procedure - */ + *******************************************************************************/ void WndProc(long iMessage, long wParam) { // ------------------------------------------------------------------------- // WM_PAINT @@ -142,11 +155,11 @@ void PaintCartStatus() { } // pickup the pointer to the string const char *esi; - //if (DriveCount) { - esi = CartStatStrings[eax]; - //} else { - // esi = szNoIomegaDrives; - //} + if (DriveCount) { + esi = CartStatStrings[eax]; + } else { + esi = szNoIomegaDrives; + } SetColor(BLACK_COLOR); TextOutCentered(115, 9, 241 - 115, 27 - 9, esi); } @@ -347,7 +360,10 @@ void TestMonitorWndProc() { * APPLICATION TIMER PROC *******************************************************************************/ void ApplicationTimerProc() { - HandleDriveChanging(); + // only if we have at least ONE Iomega drive + if(DriveCount) { + HandleDriveChanging(); + } } /******************************************************************************* diff --git a/mac-cpp-source/tip/tip.h b/mac-cpp-source/tip/tip.h index fdc637c..e0d3a8a 100644 --- a/mac-cpp-source/tip/tip.h +++ b/mac-cpp-source/tip/tip.h @@ -11,6 +11,7 @@ void run_tip(int id); #define MAXIMUM_ZIP_SPARES 126 extern long CurrentDevice; +extern long DriveCount; extern long JazDrive; // true if the current drive extern long CartridgeStatus; extern long LastLBAOnCartridge; @@ -117,6 +118,9 @@ enum { extern const char *szWindowTitle; extern const char *szCopyright_1; extern const char *szCopyright_2; +extern const char *szIomega; +extern const char *szZip; +extern const char *szJaz; extern const char *szSide0; extern const char *szSide1; extern const char *szSpaceDashSpace; @@ -202,6 +206,7 @@ void PreventProgramExit(); void AllowProgramExit(); void ErrorSound(); void ProcessPendingMessages(); +void WinMain(int Device); void WndProc(long iMessage, long wParam); void TestMonitorWndProc(); void ApplicationTimerProc(); @@ -209,6 +214,7 @@ void TestButtonClicked(); void GetCommandDetails(char command, char &cmd_flags, char &cmd_length); long SCSICommand(short Device, char *lpCmdBlk, void *lpIoBuf, short IoBufLen); +void EnumerateIomegaDevices(long Device); long GetModePage(short Device, short PageToGet, void *pBuffer, short BufLen); long SetModePage(short Device, void *pBuffer); void ModifyModePage(char *PageBuff, char eec, char retries); diff --git a/mac-cpp-source/tip/tip_aspi.cpp b/mac-cpp-source/tip/tip_aspi.cpp index 64575be..5beaa44 100644 --- a/mac-cpp-source/tip/tip_aspi.cpp +++ b/mac-cpp-source/tip/tip_aspi.cpp @@ -10,6 +10,7 @@ #define MAKE_LITTLE_ENDIAN(a) a // Don't do anything on 68000 #define MAKE_BIG_ENDIAN(a) a // Don't do anything on 68000 +// The following crashes on the 68000 due to unaligned access //#define BYTE_AT(s, a) *((char*)(s + a)) //#define WORD_AT(s, a) *((short*)(s + a)) //#define DWORD_AT(s, a) *((long*)(s + a)) @@ -101,6 +102,7 @@ enum { }; long CurrentDevice = 0; +long DriveCount = 0; long JazDrive = 0; // true if the current drive long CartridgeStatus = DISK_NOT_PRESENT; @@ -213,6 +215,38 @@ long SCSICommand(short Device, char *lpCmdBlk, void *lpIoBuf, short IoBufLen) { } } +/******************************************************************************* + * ENUMERATE IOMEGA DEVICES + *******************************************************************************/ +void EnumerateIomegaDevices(long Device) { + DriveCount = 0; + JazDrive = 0; + //----------------------------------------------------------- + char InqData[96]; + char Scsi[6] = {0}; + Scsi[0] = SCSI_Cmd_Inquiry; + Scsi[4] = sizeof(InqData); + long eax = SCSICommand(Device, Scsi, InqData, sizeof(InqData)); + if(eax) goto TryNextDrive; + //----------------------------------------------------------- + InqData[14] = '\0'; + if (strcmp(szIomega, InqData + 8)) goto TryNextDrive; + //----------------------------------------------------------- + InqData[19] = '\0'; + if (!strcmp(szZip, InqData + 16)) goto FoundZipOrJaz; + //----------------------------------------------------------- + if (strcmp(szJaz, InqData + 16)) goto TryNextDrive; + JazDrive = 1; + FoundZipOrJaz: + DriveCount = 1; + if(JazDrive) + printf("Found Jaz drive\n"); + else + printf("Found Zip drive\n"); +TryNextDrive: + return; +} + /******************************************************************************* * GET MODE PAGE *******************************************************************************/ @@ -262,8 +296,8 @@ void SetErrorRecovery(bool Retries, bool ECC, bool Testing) { char PageBuff[40]; #ifdef NO_EXCESS_READS - // Limit reads to 20 bytes to prevent controller errors - GetModePage(CurrentDevice, ERROR_RECOVERY_PAGE, PageBuff, 20); + // Limit reads to 20 bytes on Zip to prevent controller errors + GetModePage(CurrentDevice, ERROR_RECOVERY_PAGE, PageBuff, JazDrive ? sizeof(PageBuff) : 20); #else GetModePage(CurrentDevice, ERROR_RECOVERY_PAGE, PageBuff, sizeof(PageBuff)); #endif @@ -370,7 +404,7 @@ long GetSpareSectorCounts(char checkPassword) { // here... might be better to conditionally check for Jaz drive char DiskStat[72]; #ifdef NO_EXCESS_READS - eax = GetNonSenseData(CurrentDevice, DISK_STATUS_PAGE, DiskStat, 63); + eax = GetNonSenseData(CurrentDevice, DISK_STATUS_PAGE, DiskStat, JazDrive ? sizeof(DiskStat) : 63); if (eax) return eax; #else eax = GetNonSenseData(CurrentDevice, DISK_STATUS_PAGE, DiskStat, sizeof(DiskStat)); @@ -454,7 +488,7 @@ void HandleDriveChanging() { long eax; char DiskStat[72]; #ifdef NO_EXCESS_READS - eax = GetNonSenseData(CurrentDevice, DISK_STATUS_PAGE, DiskStat, 63); + eax = GetNonSenseData(CurrentDevice, DISK_STATUS_PAGE, DiskStat, JazDrive ? sizeof(DiskStat) : 63); if (eax) return; #else eax = GetNonSenseData(CurrentDevice, DISK_STATUS_PAGE, DiskStat, sizeof(DiskStat)); diff --git a/mac-cpp-source/tip/tip_main.cpp b/mac-cpp-source/tip/tip_main.cpp index fa845b7..2515c59 100644 --- a/mac-cpp-source/tip/tip_main.cpp +++ b/mac-cpp-source/tip/tip_main.cpp @@ -27,7 +27,7 @@ void DoMouseMove(EventRecord &event, RgnHandle *cursorRegion); void DoDiskEvent(EventRecord &event); void run_tip(int id) { - CurrentDevice = id; + WinMain(id); RgnHandle cursorRgn = NewRgn(); NewTipWindow(); diff --git a/mac-cpp-source/tip/tip_text.cpp b/mac-cpp-source/tip/tip_text.cpp index 015d91c..e1d3bf3 100644 --- a/mac-cpp-source/tip/tip_text.cpp +++ b/mac-cpp-source/tip/tip_text.cpp @@ -4,6 +4,10 @@ const char *szWindowTitle = "TIP 2.1b -- Zip & Jaz Drive and Cartridge Testing S const char *szCopyright_1 = "Copyright (c) 2006 by"; const char *szCopyright_2 = "Gibson Research Corp."; +const char *szIomega = "IOMEGA"; +const char *szZip = "ZIP"; +const char *szJaz = "JAZ"; + const char *szSide0 = "Side 0"; const char *szSide1 = "Side 1"; const char *szSpaceDashSpace = " - ";