Bug fixes, whitespace cleanup, deleted binaries.

This commit is contained in:
Marcio T
2021-11-24 08:55:06 -07:00
parent 4db47b680f
commit 5e33fa482c
40 changed files with 360 additions and 338 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 410 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 410 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 410 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 410 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 410 B

View File

@@ -8,7 +8,7 @@
#include "tip.h"
// ----------------------- Test Monitor Panel Definitions -------------------
// ----------------------- Test Monitor Panel Definitions -------------------
#define SET_RECT(LEFT, TOP, RIGHT, BOTTOM) {TOP, LEFT, BOTTOM, RIGHT}
Rect CS_Stat = SET_RECT(114, 8, 242, 28);
@@ -25,72 +25,72 @@ Rect SE_Rect = SET_RECT(222, 154, 255, 221);
* This is the system's main window procedure
*/
void WndProc(long iMessage, long wParam) {
// -------------------------------------------------------------------------
// WM_PAINT
// -------------------------------------------------------------------------
if (iMessage == WM_PAINT) {
// Draw the Lower Horz Button Divider
// -------------------------------------------------------------------------
// WM_PAINT
// -------------------------------------------------------------------------
if (iMessage == WM_PAINT) {
// Draw the Lower Horz Button Divider
SetColor(GRAY_COLOR);
MoveTo(15, 289);
LineTo(446, 289);
SetColor(WHITE_COLOR);
LineTo(446, 290);
LineTo(14, 290);
SetColor(GRAY_COLOR);
MoveTo(15, 289);
LineTo(446, 289);
SetColor(WHITE_COLOR);
LineTo(446, 290);
LineTo(14, 290);
// Paint the Copyright Notice
SetColor(GRAY_COLOR);
TextOut(15, 298, szCopyright_1);
TextOut(15, 311, szCopyright_2);
// Paint the Copyright Notice
SetColor(GRAY_COLOR);
TextOut(15, 298, szCopyright_1);
TextOut(15, 311, szCopyright_2);
}
// -------------------------------------------------------------------------
// WM_COMMAND : a button was pressed
// -------------------------------------------------------------------------
else if (iMessage == WM_COMMAND) {
switch(wParam) {
case IDB_QUIT:
if (TestingPhase < TESTING_STARTUP) {
PostQuitMessage();
}
break;
case IDB_TEST:
switch(CartridgeStatus) {
case DISK_SPUN_DOWN:
SpinUpIomegaCartridge(CurrentDevice);
break;
case DISK_AT_SPEED:
printf("Testing the disk\n");
if(TestingPhase != READY_TO_TEST) {
PrepareToBeginTesting();
}
TestTheDisk();
printf("Test finished\n");
break;
case DISK_TEST_UNDERWAY:
UserInterrupt = 1;
break;
case DISK_Z_TRACK_FAILURE:
case DISK_TEST_FAILURE:
case DISK_PROTECTED:
//EjectIomegaCartridge();
break;
case DISK_LOW_SPARES:
PrepareToBeginTesting();
break;
}
break;
// -------------------------------------------------------------------------
// WM_COMMAND : a button was pressed
// -------------------------------------------------------------------------
else if (iMessage == WM_COMMAND) {
switch(wParam) {
case IDB_QUIT:
if (TestingPhase < TESTING_STARTUP) {
PostQuitMessage();
}
break;
case IDB_TEST:
switch(CartridgeStatus) {
case DISK_SPUN_DOWN:
SpinUpIomegaCartridge(CurrentDevice);
break;
case DISK_AT_SPEED:
printf("Testing the disk\n");
if(TestingPhase != READY_TO_TEST) {
PrepareToBeginTesting();
}
TestTheDisk();
printf("Test finished\n");
break;
case DISK_TEST_UNDERWAY:
UserInterrupt = 1;
break;
case DISK_Z_TRACK_FAILURE:
case DISK_TEST_FAILURE:
case DISK_PROTECTED:
//EjectIomegaCartridge();
break;
case DISK_LOW_SPARES:
PrepareToBeginTesting();
break;
}
break;
default:
break;
}
}
break;
}
}
}
BtnList tipBtns[] = {
{IDB_TEST, szPressToStart, 200, 301, 160, 24, true}, // Added by MLT
{IDB_BACK, szBack, 185-28, 301, 80, 24, false},
{IDB_NEXT, szNext, 264-28, 301, 80, 24, false},
{IDB_QUIT, szQuit, 367+35, 301, 45, 24, true},
{0, 0, 0, 0, 0, 0, 0}
{IDB_TEST, szPressToStart, 200, 301, 160, 24, true}, // Added by MLT
{IDB_BACK, szBack, 185-28, 301, 80, 24, false},
{IDB_NEXT, szNext, 264-28, 301, 80, 24, false},
{IDB_QUIT, szQuit, 367+35, 301, 45, 24, true},
{0, 0, 0, 0, 0, 0, 0}
};
/*******************************************************************************
@@ -155,7 +155,7 @@ void PaintCartStatus() {
* PAINT BAR GRAPH
*******************************************************************************/
void PaintBarGraph(int Xleft, int Ytop, int XWidth, int YHeight, long BarColor, long BarValue, char *pRightText, bool Active) {
// fill the entire rectangle with background gray
// fill the entire rectangle with background gray
SetColor(BACK_COLOR);
Rectangle(Xleft, Ytop, Xleft + XWidth, Ytop + YHeight);
if (Active) { // now fleshout the bar ONLY IF we're active
@@ -170,11 +170,11 @@ void PaintBarGraph(int Xleft, int Ytop, int XWidth, int YHeight, long BarColor,
Rectangle(Xleft, Ytop, Xleft + AbsoluteBarWidth, Ytop + YHeight);
// now place the floating percentage into the middle (if it fits there)
if(BarValue) {
char PercentString[8];
sprintf(PercentString, szBarChartPercent, BarValue);
SetColor(WHITE_COLOR);
TextOutCentered(Xleft, Ytop, AbsoluteBarWidth, YHeight, PercentString);
char PercentString[8];
sprintf(PercentString, szBarChartPercent, BarValue);
SetColor(WHITE_COLOR);
TextOutCentered(Xleft, Ytop, AbsoluteBarWidth, YHeight, PercentString);
}
}
}
@@ -193,17 +193,21 @@ void PaintTheBarGraphs(bool Active) {
if(ebx > ecx) { // if Spares > MAXIMUM
ebx = ecx; // clip Spares down to MAX
}
PaintBarGraph(13, 95, 395, 30, RED_COLOR, ebx*100/ecx, NULL, Active);
PaintBarGraph(13, 95, 395, 30, RED_COLOR, CvrtIntoPrcnt(ebx, ecx), NULL, Active);
} else {
ebx = Side_0_SparesCount;
ecx = MAXIMUM_ZIP_SPARES;
PaintBarGraph(13, 95, 395, 14, RED_COLOR, ebx*100/ecx, "Side 0", Active);
PaintBarGraph(13, 95, 395, 14, RED_COLOR, CvrtIntoPrcnt(ebx, ecx), "Side 0", Active);
ebx = Side_1_SparesCount;
ecx = MAXIMUM_ZIP_SPARES;
PaintBarGraph(13, 111, 395, 14, RED_COLOR, ebx*100/ecx, "Side 1", Active);
PaintBarGraph(13, 111, 395, 14, RED_COLOR, CvrtIntoPrcnt(ebx, ecx), "Side 1", Active);
}
}
int CvrtIntoPrcnt(long val, long max) {
return 100 - val*100/max;
}
/*******************************************************************************
* PAINT CENTERED STRING
*
@@ -251,7 +255,7 @@ void PaintTestStatistics(bool Active) {
}
sprintf(szString, szCenteredDecimal, eax);
strcat(szString, szSpaceDashSpace);
eax = FirstLBASector + NumberOfLBAs;
eax = FirstLBASector + NumberOfLBAs - 1;
if (TestingPhase == READY_TO_TEST) {
eax = LastLBAOnCartridge;
}
@@ -262,8 +266,8 @@ void PaintTestStatistics(bool Active) {
// show the LastError
char *errStr = 0;
for (int i = 0; errorTypeList[i].str; i++) {
errStr = errorTypeList[i].str;
if (errorTypeList[i].code == LastError) break;
errStr = errorTypeList[i].str;
if (errorTypeList[i].code == LastError) break;
}
PaintCenteredString(76, 172, 126, 14, errStr, Active);
@@ -345,12 +349,12 @@ void TestMonitorWndProc() {
*******************************************************************************/
void UpdateRunTimeDisplay() {
GetDC(hTestMonitor);
PaintTestPhase();
PaintTheBarGraphs(true);
PaintTestStatistics(true);
PaintCartStatus();// Added by MLT
ReleaseDC(hTestMonitor);
GetDC(hTestMonitor);
PaintTestPhase();
PaintTheBarGraphs(true);
PaintTestStatistics(true);
PaintCartStatus();// Added by MLT
ReleaseDC(hTestMonitor);
}
/*******************************************************************************
@@ -358,11 +362,11 @@ void UpdateRunTimeDisplay() {
*******************************************************************************/
void UpdateCurrentSector() {
GetDC(hTestMonitor);
char szString[40];
sprintf(szString, szCenteredDecimal, SingleTransferLBA);
PaintCenteredString(76, 155, 126, 14, szString, true);
ReleaseDC(hTestMonitor);
GetDC(hTestMonitor);
char szString[40];
sprintf(szString, szCenteredDecimal, SingleTransferLBA);
PaintCenteredString(76, 155, 126, 14, szString, true);
ReleaseDC(hTestMonitor);
}
/*******************************************************************************
@@ -370,9 +374,9 @@ void UpdateCurrentSector() {
*******************************************************************************/
void UpdateRunPhaseDisplay() {
GetDC(hTestMonitor);
PaintTestPhase();
ReleaseDC(hTestMonitor);
GetDC(hTestMonitor);
PaintTestPhase();
ReleaseDC(hTestMonitor);
}
/*******************************************************************************
@@ -380,4 +384,5 @@ void UpdateRunPhaseDisplay() {
*******************************************************************************/
void ErrorSound() {
SysBeep(10);
}

View File

@@ -3,7 +3,7 @@ typedef Boolean bool;
extern WindowPtr tipWindow;
void run_tip();
void run_tip(int id);
#define MINIMUM_JAZ_SPARES 500
#define MAXIMUM_JAZ_SPARES 2557
@@ -70,13 +70,13 @@ unsigned long GetSystemTime();
#define hMainWnd 0, 40
#define GetDC(h) {GrafPtr oldPort; \
GetPort(&oldPort); \
SetPort(tipWindow); \
SetOrigin(h);
GetPort(&oldPort); \
SetPort(tipWindow); \
SetOrigin(h);
#define ReleaseDC(h) SetOrigin(0,0); \
SetPort(oldPort);}
// ------------------------------ Cartridge Status -------------------------------
@@ -162,9 +162,9 @@ extern const char *szBack;
extern const char *szNext;
extern const char *szQuit;
#define IDB_BACK 0xFF00
#define IDB_NEXT 0xFF01
#define IDB_QUIT 0xFF02
#define IDB_BACK 0xFF00
#define IDB_NEXT 0xFF01
#define IDB_QUIT 0xFF02
#define IDB_TEST 0xFF03
typedef struct {long id; const char *name; int x; int y; int w; int h; bool visible;} BtnList;
@@ -180,6 +180,7 @@ void SunkenFields(Rect *pFirstRect, long count, long yspacing);
void PaintCartStatus();
void PaintTextArray(TextList *list, long color);
void PaintBarGraph(int Xleft, int Ytop, int XWidth, int YHeight, long BarColor, long BarValue, char *pRightText, bool Active);
int CvrtIntoPrcnt(long val, long max);
void PaintTestPhase();
void PaintTheBarGraphs(bool Active);
void PaintTestStatistics(bool Active);

View File

@@ -5,6 +5,7 @@
#include "tip.h"
//#define DEMO
#define NO_EXCESS_READS
#define BYTE_AT(a) *((char*)&(a))
#define WORD_AT(a) *((short*)&(a))
@@ -25,9 +26,9 @@
#define JAZ_2GB_BOOT 0x0E00
struct DEFECT_LIST_HEADER {
char DLH_reserved; // (00h)
char DLH_BitFlags; // [000] [P] [G] [xxx - defect list format]
char DLH_DefectListLength;
char DLH_reserved; // (00h)
char DLH_BitFlags; // [000] [P] [G] [xxx - defect list format]
short DLH_DefectListLength;
};
//-------------------------- Drive Array Status Flags ---------------------------
@@ -60,7 +61,7 @@ struct DEFECT_LIST_HEADER {
#define DRIVE_A_SUPPORT_BIAS 32 // reduce total by 32 for DRIVE A support
#define BYTES_PER_SECTOR 512
#define MAX_SECTORS_PER_TEST 20
#define MAX_SECTORS_PER_TEST 50
#define BADNESS_THRESHOLD 10
@@ -170,23 +171,22 @@ long SCSICommand(short Device, char *lpCmdBlk, void *lpIoBuf, short IoBufLen) {
// call the SCSI interface to forward the command to the device
OSErr err = scsi_cmd(Device, lpCmdBlk, cmd_length, lpIoBuf, IoBufLen, 0, cmd_flags, &cmd_status);
if(err != noErr) {
return SS_ERR;
return SS_ERR;
}
if(cmd_status == 0) {
printf("SCSI OK\n");
// if the command did not generate any Sense Data, just return NULL
return 0;
}
else if(cmd_status == 2) { // Check Condition
printf("SCSI CHK CONDITION\n");
// Request sense data
scsi_sense_reply sense_data;
scsi_request_sense_data(Device, &sense_data);
printf("SCSI CHECK CONDITION (KEY %x, ASC %x, ASCQ %x)\n", sense_data.key, sense_data.asc, sense_data.ascq);
// okay, we have an SS_ERR condition, let's check the SENSE DATA
// assemble [00 ASC ASCQ SenseKey]
return (sense_data.asc << 16) ||
(sense_data.ascq << 8) ||
sense_data.key;
return (long(sense_data.asc) << 16) |
(long(sense_data.ascq) << 8) |
(long(sense_data.key) );
}
else {
// else, if it's *NOT* a "Sense Data" error (SS_ERR)
@@ -209,9 +209,13 @@ long GetModePage(short Device, short PageToGet, void *pBuffer, short BufLen) {
* SET MODE PAGE
*******************************************************************************/
long SetModePage(short Device, void *pBuffer) {
char Scsi[6] = {0}; // init the SCSI parameter block
char* ebx = (char*) pBuffer; // get a pointer to the top of buffer
char ecx = ebx[0] + 1; // adjust it up by one
ebx[0] = 0; // now clear the two reserved bytes
ebx[2] = 0;
char Scsi[6] = {0}; // init the SCSI parameter block
Scsi[0] = SCSI_Cmd_ModeSelect; // set the command
Scsi[1] = 0x10; // set the Page Format bit
Scsi[4] = ecx; // set the parameter list length
@@ -237,7 +241,13 @@ void ModifyModePage(char *PageBuff, char ecc, char retries) {
void SetErrorRecovery(bool Retries, bool ECC, bool Testing) {
char PageBuff[40];
GetModePage(CurrentDevice, ERROR_RECOVERY_PAGE, PageBuff, sizeof(PageBuff));
#ifdef NO_EXCESS_READS
// Limit reads to 20 bytes to prevent controller errors
GetModePage(CurrentDevice, ERROR_RECOVERY_PAGE, PageBuff, 20);
#else
GetModePage(CurrentDevice, ERROR_RECOVERY_PAGE, PageBuff, sizeof(PageBuff));
#endif
#define EARLY_RECOVERY 0x08
#define PER 0x04
@@ -260,7 +270,7 @@ void SetErrorRecovery(bool Retries, bool ECC, bool Testing) {
retries = 0;
ModifyModePage(PageBuff, ecc, retries);
long eax = SetModePage(CurrentDevice, PageBuff);
const long eax = SetModePage(CurrentDevice, PageBuff);
// if we had an invalid field in the CDB (the EER bit was on)
if (eax == 0x00260005) {
GetModePage(CurrentDevice, ERROR_RECOVERY_PAGE, PageBuff, sizeof(PageBuff));
@@ -339,8 +349,13 @@ void GetSpareSectorCounts(bool) {
// rather than 72; it looks like this code is causing a SCSI transfer error
// here... might be better to conditionally check for Jaz drive
char DiskStat[72];
eax = GetNonSenseData(CurrentDevice, DISK_STATUS_PAGE, DiskStat, sizeof(DiskStat));
if (!eax) /*goto ListChk;*/ return;
#ifdef NO_EXCESS_READS
eax = GetNonSenseData(CurrentDevice, DISK_STATUS_PAGE, DiskStat, 63);
if (eax) return;
#else
eax = GetNonSenseData(CurrentDevice, DISK_STATUS_PAGE, DiskStat, sizeof(DiskStat));
if (!eax) /*goto ListChk;*/ return;
#endif
// --------------------------------------------------------------------------
ch = 0; // clear the DRIVE_A_SUPPORT
if (JazDrive) {
@@ -378,6 +393,7 @@ void GetSpareSectorCounts(bool) {
Side_0_SparesCount = eax;
MAKE_LITTLE_ENDIAN(ebx); // make it little endian
Side_1_SparesCount = ebx;
// compute the number of troubles we encountered during the testing
FirmErrors = Initial_Side_0_Spares - Side_0_SparesCount;
FirmErrors += Initial_Side_1_Spares - Side_1_SparesCount;
@@ -386,6 +402,7 @@ void GetSpareSectorCounts(bool) {
CartridgeStatus = DISK_TEST_FAILURE;
return;
}
// MLT: The code for removing the ZIP protection has been omitted
return; // return zero since no error
}
@@ -423,16 +440,16 @@ void PrepareToBeginTesting() {
HardErrors = 0;
UserInterrupt = 0;
LastError = 0;
#ifdef DEMO
LastLBAOnCartridge = 99999;
SoftErrors = 6;
FirmErrors = 2;
HardErrors = 1;
UserInterrupt = 0;
LastError = 0x0C8001;
Side_0_SparesCount = 12;
Side_1_SparesCount = 20;
#endif
#ifdef DEMO
LastLBAOnCartridge = 99999;
SoftErrors = 6;
FirmErrors = 2;
HardErrors = 1;
UserInterrupt = 0;
LastError = 0x0C8001;
Side_0_SparesCount = 12;
Side_1_SparesCount = 20;
#endif
}
/*******************************************************************************
@@ -462,20 +479,19 @@ void BumpErrorCounts(long ErrorCode) {
* PERFORM REGION TRANSFER
*******************************************************************************/
long PerformRegionTransfer(short XferCmd, void *pBuffer) {
return -1;
char Scsi[10] = {0}; // clear out the SCSI CDB
const long InitialHardErrors = HardErrors;
SetErrorRecovery(false, false, true); // disable Retries & ECC
Scsi[0] = XferCmd;
DWORD_AT(Scsi[2]) = MAKE_BIG_ENDIAN(FirstLBASector); // WHICH LBA's to read, BIG endian
WORD_AT(Scsi[7]) = MAKE_BIG_ENDIAN(NumberOfLBAs); // HOW MANY to read, BIG endian
long eax = SCSICommand(CurrentDevice, Scsi, pBuffer, NumberOfLBAs * BYTES_PER_SECTOR);
return 1;
// if we failed somewhere during our transfer ... let's zero in on it
if (eax) {
printf("Error during transfer %lx (lba: %ld)\n", eax, FirstLBASector);
if ( eax == SS_ERR || // if it's a CONTROLLER ERROR, skip!
eax == BUFFER_TOO_BIG ||
eax == LBA_TOO_LARGE) {
@@ -485,39 +501,39 @@ long PerformRegionTransfer(short XferCmd, void *pBuffer) {
//--------------------------------------------------------------------------
// Save error and current Soft + Hard Error count to see if we do FIND the glitch ...
const long GlitchError = eax; // save the error which stopped us!
const long GlitchCount = SoftErrors + HardErrors;
const long GlitchCount = SoftErrors + HardErrors;
char *LocalBuffer = (char*) pBuffer;
ErrorSound();
SingleTransferLBA = FirstLBASector;
SingleTransferLBA = FirstLBASector;
// Perform transfer LBA block at a time
for(long i = 0; i < NumberOfLBAs; ++i) {
UpdateCurrentSector();
UpdateCurrentSector();
// setup for our series of transfer tests ...
// disable all recovery techniques
SetErrorRecovery(false, false, true); // disable Retries & ECC
memset(Scsi, 0, sizeof(Scsi)); // clear out the SCSI CDB
Scsi[0] = XferCmd;
DWORD_AT(Scsi[2]) = MAKE_BIG_ENDIAN(SingleTransferLBA); // WHICH LBA to read, BIG endian
WORD_AT(Scsi[7]) = MAKE_BIG_ENDIAN(1); // a single sector
eax = SCSICommand(CurrentDevice, Scsi, LocalBuffer, BYTES_PER_SECTOR);
if (eax) {
// some sort of problem encountered!
if (eax == SS_ERR) goto Exit; // if it's a CONTROLLER ERROR, skip!
if (eax & 0xFF == 1) goto PostTheError; // did we recover?
if (eax & 0xFF == 1) goto PostTheError; // did we recover?
SetErrorRecovery(true, false, true); // enable retries
eax = SCSICommand(CurrentDevice, Scsi, LocalBuffer, BYTES_PER_SECTOR);
if (eax) {
// failed with retries
if (eax == SS_ERR) goto Exit; // if it's a CONTROLLER ERROR, skip!
if (eax & 0xFF == 1) goto PostTheError; // did we recover?
SetErrorRecovery(true, true, true); // enable retries AND EEC
eax = SCSICommand(CurrentDevice, Scsi, LocalBuffer, BYTES_PER_SECTOR);
if (eax) {
@@ -539,14 +555,14 @@ long PerformRegionTransfer(short XferCmd, void *pBuffer) {
BumpErrorCounts(eax); // given eax, count the errors
GetSpareSectorCounts(false); // update the Cart's Condition
UpdateRunTimeDisplay();
LocalBuffer += BYTES_PER_SECTOR;
SingleTransferLBA++;
if(UserInterrupt) break;
if(UserInterrupt) break;
}
LocalBuffer += BYTES_PER_SECTOR;
SingleTransferLBA++;
ProcessPendingMessages();
}
// now see whether we *did* found something to complain about ...
eax = SoftErrors + HardErrors;
if (eax == GlitchCount) {
@@ -582,34 +598,37 @@ long TestTheDisk() {
void *pPatternBuffer = malloc(MAX_SECTORS_PER_TEST * BYTES_PER_SECTOR);
void *pUserDataBuffer = malloc(MAX_SECTORS_PER_TEST * BYTES_PER_SECTOR);
if(pPatternBuffer == NULL || pUserDataBuffer == NULL) {
printf("Allocation error\n");
return -1;
}
if(pPatternBuffer == NULL || pUserDataBuffer == NULL) {
printf("Allocation error\n");
return -1;
}
CartridgeStatus = DISK_TEST_UNDERWAY;
TestingPhase = TESTING_STARTUP; // inhibit stopping now
SetButtonText(szPressToStop);
LockCurrentDrive(); // prevent media removal
GetSpareSectorCounts(false); // update the Cart's Condition
UpdateRunTimeDisplay();
// Standard Testing Operation
StartingInstant = GetSystemTime();
do {
ProcessPendingMessages();
NumberOfLBAs = MAX_SECTORS_PER_TEST;
if(LastLBAOnCartridge) {
if (FirstLBASector + NumberOfLBAs > LastLBAOnCartridge + 1) {
NumberOfLBAs = LastLBAOnCartridge - FirstLBASector + 1;
}
// compute the percentage complete
PercentComplete = FirstLBASector * 100 / LastLBAOnCartridge;
}
if(NumberOfLBAs == 0) break;
ProcessPendingMessages();
NumberOfLBAs = MAX_SECTORS_PER_TEST;
if(LastLBAOnCartridge) {
if (FirstLBASector + NumberOfLBAs > LastLBAOnCartridge + 1) {
NumberOfLBAs = LastLBAOnCartridge - FirstLBASector + 1;
}
// compute the percentage complete
PercentComplete = FirstLBASector * 100 / LastLBAOnCartridge;
}
if(NumberOfLBAs == 0) break;
// uppdate the elapsed time
SecondsElapsed = GetElapsedTimeInSeconds();
@@ -617,17 +636,17 @@ long TestTheDisk() {
// get a random pattern of data to write
const long DataPattern = rand();
memset(pPatternBuffer, DataPattern, sizeof(pPatternBuffer));
// update the cartridge's status
GetSpareSectorCounts(false); // update the Cart's Condition
TestingPhase = READING_DATA;
UpdateRunTimeDisplay();
long eax = PerformRegionTransfer(SCSI_Cmd_ReadMany, pUserDataBuffer);
if(eax == 0) {
/*if(eax == 0) {
// -------------------------------
TestingPhase = WRITING_PATT;
UpdateRunPhaseDisplay();
@@ -646,17 +665,17 @@ long TestTheDisk() {
goto GetOut;
}
if (CartridgeStatus != DISK_TEST_UNDERWAY) {
break;
}
break;
}*/
// bump the FirstLBASector up for the next transfer
FirstLBASector += NumberOfLBAs;
} while(!UserInterrupt);
// show that we're post-test
GetOut:
free(pPatternBuffer);
free(pUserDataBuffer);
free(pPatternBuffer);
free(pUserDataBuffer);
TestingPhase = UNTESTED;
UnlockCurrentDrive();
SetErrorRecovery(true, true, false); // reenable Retries & ECC

View File

@@ -22,16 +22,17 @@ void DoUpdate(WindowPtr window);
void DoMouseDown(EventRecord &event);
void DoMouseMove(EventRecord &event, RgnHandle *cursorRegion);
void run_tip(void) {
RgnHandle cursorRgn = NewRgn();
void run_tip(int id) {
CurrentDevice = id;
RgnHandle cursorRgn = NewRgn();
NewTipWindow();
gDone = false;
do {
EventRecord event;
if (WaitNextEvent(everyEvent, &event, GetCaretTime(), cursorRgn)) {
DoEvent(event, &cursorRgn);
}
EventRecord event;
if (WaitNextEvent(everyEvent, &event, GetCaretTime(), cursorRgn)) {
DoEvent(event, &cursorRgn);
}
} while (!gDone);
DestroyTipWindow();
@@ -50,14 +51,14 @@ void NewTipWindow() {
rect.bottom = rect.top + 336 - 35;
rect.right = rect.left + 467;
Str255 title;
StrToPascal(title, szWindowTitle);
Str255 title;
StrToPascal(title, szWindowTitle);
tipWindow = AllowColor ?
NewCWindow(NULL,&rect, title, true, 0, 0, true, 0) :
NewWindow(NULL,&rect, title, true, 0, 0, true, 0);
GetDC(hMainWnd);
GetDC(hMainWnd);
if (AllowColor) {
SetColor(BACK_COLOR);
RGBColor bgColor;
@@ -65,24 +66,30 @@ void NewTipWindow() {
RGBBackColor(&bgColor);
}
TextSize(10);
for(int i = 0; tipBtns[i].name; i++) {
if (!tipBtns[i].visible) continue;
SetRect(&rect,
tipBtns[i].x,
tipBtns[i].y,
tipBtns[i].x + tipBtns[i].w,
tipBtns[i].y + tipBtns[i].h
);
StrToPascal(title, tipBtns[i].name);
ControlHandle h = NewControl(tipWindow, &rect, title, true, 0, 0, 0, 0, tipBtns[i].id);
if(tipBtns[i].id == IDB_TEST) {
actionBtn = h;
}
for(int i = 0; tipBtns[i].name; i++) {
if (!tipBtns[i].visible) continue;
SetRect(&rect,
tipBtns[i].x,
tipBtns[i].y,
tipBtns[i].x + tipBtns[i].w,
tipBtns[i].y + tipBtns[i].h
);
StrToPascal(title, tipBtns[i].name);
ControlHandle h = NewControl(tipWindow, &rect, title, true, 0, 0, 0, 0, tipBtns[i].id);
if(tipBtns[i].id == IDB_TEST) {
actionBtn = h;
}
}
ReleaseDC(hMainWnd);
// Initialize tip
PrepareToBeginTesting();
GetSpareSectorCounts(false);
FirmErrors = 0;
UpdateRunTimeDisplay();
}
void DestroyTipWindow() {
@@ -91,9 +98,9 @@ void DestroyTipWindow() {
void DoEvent(EventRecord &event, RgnHandle *cursorRgn) {
if(!SIOUXHandleOneEvent(&event)) {
// If SIOUX didn't handle the event, then handle it ourselves
// If SIOUX didn't handle the event, then handle it ourselves
switch(event.what) {
case mouseDown: DoMouseDown(event); break;
case mouseDown: DoMouseDown(event); break;
case updateEvt: DoUpdate((WindowPtr)event.message); break;
case osEvt: DoMouseMove(event, cursorRgn); break;
}
@@ -105,16 +112,16 @@ void DoUpdate(WindowPtr window) {
BeginUpdate(window);
SetPort(window);
EraseRect(&window->portRect);
GetDC(hMainWnd);
GetDC(hMainWnd);
WndProc(WM_PAINT, 0);
DrawControls(window);
ReleaseDC(hMainWnd);
GetDC(hTestMonitor);
TestMonitorWndProc();
ReleaseDC(hTestMonitor);
EndUpdate(window);
}
@@ -131,19 +138,19 @@ void DoMouseDown(EventRecord &event) {
SelectWindow(thisWindow);
}
else if(thisWindow == tipWindow) {
long id = 0;
Point mouse = event.where;
GetDC(hMainWnd);
GlobalToLocal(&mouse);
if(FindControl(mouse, thisWindow, &thisControl) == inButton) {
if(TrackControl(thisControl, mouse, 0) == inButton) {
id = GetControlReference(thisControl);
}
}
ReleaseDC(hMainWnd);
if(id) {
WndProc(WM_COMMAND, id);
}
long id = 0;
Point mouse = event.where;
GetDC(hMainWnd);
GlobalToLocal(&mouse);
if(FindControl(mouse, thisWindow, &thisControl) == inButton) {
if(TrackControl(thisControl, mouse, 0) == inButton) {
id = GetControlReference(thisControl);
}
}
ReleaseDC(hMainWnd);
if(id) {
WndProc(WM_COMMAND, id);
}
}
break;
case inDrag:
@@ -163,13 +170,13 @@ void DoMouseDown(EventRecord &event) {
void DoMouseMove(EventRecord &event, RgnHandle *cursorRgn) {
WindowPtr thisWindow;
int part = FindWindow(event.where, &thisWindow);
if (thisWindow == tipWindow) {
InitCursor();
// Set the cursorRegion to everything inside our window
if(cursorRgn) {
CopyRgn(((WindowPeek)tipWindow)->contRgn, *cursorRgn);
}
}
if (thisWindow == tipWindow) {
InitCursor();
// Set the cursorRegion to everything inside our window
if(cursorRgn) {
CopyRgn(((WindowPeek)tipWindow)->contRgn, *cursorRgn);
}
}
}
void StrToPascal(Str255 pStr, const char *str) {
@@ -202,8 +209,8 @@ void SetColor(long color) {
break;
case BLACK_COLOR:
case GRAY_COLOR:
PenPat(&qd.black);
break;
PenPat(&qd.black);
break;
case RED_COLOR:
case BLUE_COLOR:
PenPat(&qd.ltGray);
@@ -211,17 +218,17 @@ void SetColor(long color) {
case LTGRAY_COLOR:
case GREEN_COLOR:
PenPat(&qd.gray);
break;
break;
}
}
}
void SetColor(long color, long monoColor) {
if (AllowColor) {
SetColor(color);
} else {
SetColor(monoColor);
}
if (AllowColor) {
SetColor(color);
} else {
SetColor(monoColor);
}
}
/*******************************************************************************
@@ -264,7 +271,7 @@ void DrawLed(int x, int y, long color) {
*******************************************************************************/
void DrawEdge(Rect *qrc, int edge, int grfFlags) {
if(edge == BDR_SUNKENOUTER && AllowColor) {
if(edge == BDR_SUNKENOUTER && AllowColor) {
// Draw a sunken rectangle
SetColor(GRAY_COLOR);
MoveTo(qrc->left,qrc->bottom-1);
@@ -343,28 +350,28 @@ unsigned long GetSystemTime() {
* SET BUTTON TEXT
*******************************************************************************/
void SetButtonText(const char *str) {
Str255 pStr;
StrToPascal(pStr, str);
if(actionBtn) {
GetDC(hMainWnd);
SetCTitle(actionBtn, pStr);
ReleaseDC(hMainWnd);
}
Str255 pStr;
StrToPascal(pStr, str);
if(actionBtn) {
GetDC(hMainWnd);
SetCTitle(actionBtn, pStr);
ReleaseDC(hMainWnd);
}
}
/*******************************************************************************
* POST QUIT MESSAGE
*******************************************************************************/
void PostQuitMessage() {
gDone = true;
gDone = true;
}
/*******************************************************************************
* PROCESS PENDING MESSAGES
*******************************************************************************/
void ProcessPendingMessages() {
EventRecord event;
if (GetNextEvent(everyEvent, &event)) {
DoEvent(event,NULL);
}
EventRecord event;
if (GetNextEvent(everyEvent, &event)) {
DoEvent(event,NULL);
}
}

View File

@@ -1,7 +1,7 @@
#include "tip.h"
const char *szWindowTitle = "TIP 2.1b -- Zip & Jaz Drive and Cartridge Testing System";
const char *szCopyright_1 = "Copyright (c) 2006 by";
const char *szCopyright_1 = "Copyright (c) 2006 by";
const char *szCopyright_2 = "Gibson Research Corp.";
const char *szSide0 = "Side 0";
@@ -10,7 +10,7 @@ const char *szSpaceDashSpace = " - ";
const char *szBarChartPercent = " %ld%% ";
const char *szCenteredDecimal = "%ld";
const char *szCenteredHex = "ErrorCode: %06lX";
const char *szCenteredHex = "ErrorCode: %06lX";
const char *szHoursMinsSecs = "%ld:%02ld:%02ld";
const char *szCartStatus = "Cartridge Status:";