mirror of
https://github.com/marciot/mac-tip.git
synced 2024-06-12 07:29:31 +00:00
Compiler hacks for getting this to run on Mac Plus.
This commit is contained in:
parent
7607de4624
commit
0acefb2aa2
|
@ -169,12 +169,11 @@ void PaintBarGraph(int Xleft, int Ytop, int XWidth, int YHeight, long BarColor,
|
||||||
SetColor(BarColor, BLACK_COLOR);
|
SetColor(BarColor, BLACK_COLOR);
|
||||||
Rectangle(Xleft, Ytop, Xleft + AbsoluteBarWidth, Ytop + YHeight);
|
Rectangle(Xleft, Ytop, Xleft + AbsoluteBarWidth, Ytop + YHeight);
|
||||||
// now place the floating percentage into the middle (if it fits there)
|
// now place the floating percentage into the middle (if it fits there)
|
||||||
if(BarValue) {
|
if(BarValue > 0 && BarValue <= 100) {
|
||||||
char PercentString[8];
|
char PercentString[8];
|
||||||
sprintf(PercentString, szBarChartPercent, BarValue);
|
sprintf(PercentString, szBarChartPercent, BarValue);
|
||||||
SetColor(WHITE_COLOR);
|
SetColor(WHITE_COLOR);
|
||||||
TextOutCentered(Xleft, Ytop, AbsoluteBarWidth, YHeight, PercentString);
|
TextOutCentered(Xleft, Ytop, AbsoluteBarWidth, YHeight, PercentString);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ void run_tip(int id);
|
||||||
#define MAXIMUM_ZIP_SPARES 126
|
#define MAXIMUM_ZIP_SPARES 126
|
||||||
|
|
||||||
extern long CurrentDevice;
|
extern long CurrentDevice;
|
||||||
extern bool JazDrive; // true if the current drive
|
extern long JazDrive; // true if the current drive
|
||||||
extern long CartridgeStatus;
|
extern long CartridgeStatus;
|
||||||
extern long LastLBAOnCartridge;
|
extern long LastLBAOnCartridge;
|
||||||
extern unsigned long StartingInstant;
|
extern unsigned long StartingInstant;
|
||||||
|
@ -217,7 +217,7 @@ long GetNonSenseData(short Device, short DataPage, void *Buffer, short BufLen);
|
||||||
long LockCurrentDrive();
|
long LockCurrentDrive();
|
||||||
long UnlockCurrentDrive();
|
long UnlockCurrentDrive();
|
||||||
long SpinUpIomegaCartridge(short Device);
|
long SpinUpIomegaCartridge(short Device);
|
||||||
long GetSpareSectorCounts(bool);
|
long GetSpareSectorCounts(char);
|
||||||
void HandleDriveChanging();
|
void HandleDriveChanging();
|
||||||
void SetCartridgeStatusToEAX(long eax);
|
void SetCartridgeStatusToEAX(long eax);
|
||||||
long PerformRegionTransfer(short XferCmd, void *pBuffer);
|
long PerformRegionTransfer(short XferCmd, void *pBuffer);
|
||||||
|
|
|
@ -7,13 +7,30 @@
|
||||||
//#define DEMO
|
//#define DEMO
|
||||||
#define NO_EXCESS_READS
|
#define NO_EXCESS_READS
|
||||||
|
|
||||||
#define BYTE_AT(a) *((char*)&(a))
|
|
||||||
#define WORD_AT(a) *((short*)&(a))
|
|
||||||
#define DWORD_AT(a) *((long*)&(a))
|
|
||||||
|
|
||||||
#define MAKE_LITTLE_ENDIAN(a) a // Don't do anything on 68000
|
#define MAKE_LITTLE_ENDIAN(a) a // Don't do anything on 68000
|
||||||
#define MAKE_BIG_ENDIAN(a) a // Don't do anything on 68000
|
#define MAKE_BIG_ENDIAN(a) a // Don't do anything on 68000
|
||||||
|
|
||||||
|
//#define BYTE_AT(s, a) *((char*)(s + a))
|
||||||
|
//#define WORD_AT(s, a) *((short*)(s + a))
|
||||||
|
//#define DWORD_AT(s, a) *((long*)(s + a))
|
||||||
|
|
||||||
|
// Allows unaligned memory access
|
||||||
|
#define SET_BYTE_AT(s, a, v) s[a ] = v;
|
||||||
|
#define SET_WORD_AT(s, a, v) s[a ] = (v & 0xFF00) >> 8; \
|
||||||
|
s[a+1] = (v & 0x00FF);
|
||||||
|
#define SET_DWORD_AT(s, a, v) s[a ] = (v & 0xFF000000) >> 24; \
|
||||||
|
s[a+1] = (v & 0x00FF0000) >> 16; \
|
||||||
|
s[a+2] = (v & 0x0000FF00) >> 8; \
|
||||||
|
s[a+3] = (v & 0x000000FF);
|
||||||
|
|
||||||
|
#define GET_BYTE_AT(s, a) ((unsigned char)((unsigned char)s[a ]))
|
||||||
|
#define GET_WORD_AT(s, a) (((unsigned short)((unsigned char)s[a ])) << 8) | \
|
||||||
|
((unsigned short)((unsigned char)s[a+1]))
|
||||||
|
#define GET_DWORD_AT(s, a) (((unsigned long)((unsigned char)s[a ])) << 24) | \
|
||||||
|
(((unsigned long)((unsigned char)s[a+1])) << 16) | \
|
||||||
|
(((unsigned long)((unsigned char)s[a+2])) << 8) | \
|
||||||
|
((unsigned long)((unsigned char)s[a+3]))
|
||||||
|
|
||||||
// offsets to the various sector data images
|
// offsets to the various sector data images
|
||||||
|
|
||||||
#define ZIP_100_PART 0x0000
|
#define ZIP_100_PART 0x0000
|
||||||
|
@ -61,7 +78,7 @@ struct DEFECT_LIST_HEADER {
|
||||||
#define DRIVE_A_SUPPORT_BIAS 32 // reduce total by 32 for DRIVE A support
|
#define DRIVE_A_SUPPORT_BIAS 32 // reduce total by 32 for DRIVE A support
|
||||||
|
|
||||||
#define BYTES_PER_SECTOR 512
|
#define BYTES_PER_SECTOR 512
|
||||||
#define MAX_SECTORS_PER_TEST 50
|
#define MAX_SECTORS_PER_TEST 25
|
||||||
|
|
||||||
#define BADNESS_THRESHOLD 10
|
#define BADNESS_THRESHOLD 10
|
||||||
|
|
||||||
|
@ -85,8 +102,8 @@ enum {
|
||||||
|
|
||||||
long CurrentDevice = 0;
|
long CurrentDevice = 0;
|
||||||
|
|
||||||
bool JazDrive; // true if the current drive
|
long JazDrive = 0; // true if the current drive
|
||||||
long CartridgeStatus = /*DISK_NOT_PRESENT*/ DISK_AT_SPEED;
|
long CartridgeStatus = DISK_NOT_PRESENT;
|
||||||
|
|
||||||
unsigned long StartingInstant;
|
unsigned long StartingInstant;
|
||||||
|
|
||||||
|
@ -288,6 +305,7 @@ void SetErrorRecovery(bool Retries, bool ECC, bool Testing) {
|
||||||
* Given Adapter, Device, DataPage, and a Buffer to receive the data, this
|
* Given Adapter, Device, DataPage, and a Buffer to receive the data, this
|
||||||
* fills the buffer we're given and returns with the SCSI Completion Code
|
* fills the buffer we're given and returns with the SCSI Completion Code
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
long GetNonSenseData(short Device, short DataPage, void *Buffer, short BufLen) {
|
long GetNonSenseData(short Device, short DataPage, void *Buffer, short BufLen) {
|
||||||
char Scsi[6] = {0};
|
char Scsi[6] = {0};
|
||||||
Scsi[0] = SCSI_Cmd_NonSenseData; // do a Non-Sense Data Read
|
Scsi[0] = SCSI_Cmd_NonSenseData; // do a Non-Sense Data Read
|
||||||
|
@ -333,7 +351,7 @@ long SpinUpIomegaCartridge(short Device) {
|
||||||
* into the RichText control, else it sets the number of spares available
|
* into the RichText control, else it sets the number of spares available
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
long GetSpareSectorCounts(bool) {
|
long GetSpareSectorCounts(char checkPassword) {
|
||||||
DEFECT_LIST_HEADER DefectHeader;
|
DEFECT_LIST_HEADER DefectHeader;
|
||||||
long eax = 0, ebx, edx;
|
long eax = 0, ebx, edx;
|
||||||
short ch, cl;
|
short ch, cl;
|
||||||
|
@ -356,28 +374,28 @@ long GetSpareSectorCounts(bool) {
|
||||||
if (eax) return eax;
|
if (eax) return eax;
|
||||||
#else
|
#else
|
||||||
eax = GetNonSenseData(CurrentDevice, DISK_STATUS_PAGE, DiskStat, sizeof(DiskStat));
|
eax = GetNonSenseData(CurrentDevice, DISK_STATUS_PAGE, DiskStat, sizeof(DiskStat));
|
||||||
if (!eax) /*goto ListChk;*/ return eax;
|
if (!eax) return eax;
|
||||||
#endif
|
#endif
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
ch = 0; // clear the DRIVE_A_SUPPORT
|
ch = 0; // clear the DRIVE_A_SUPPORT
|
||||||
if (JazDrive) {
|
if (JazDrive) {
|
||||||
eax = WORD_AT(DiskStat[JAZ_SPARES_COUNT_OFFSET]);
|
eax = GET_WORD_AT(DiskStat, JAZ_SPARES_COUNT_OFFSET);
|
||||||
ebx = 0;
|
ebx = 0;
|
||||||
cl = BYTE_AT(DiskStat[JAZ_PROTECT_MODE_OFFSET]);
|
cl = GET_BYTE_AT(DiskStat, JAZ_PROTECT_MODE_OFFSET);
|
||||||
edx = DWORD_AT(DiskStat[JAZ_LAST_LBA_OFFSET]);
|
edx = GET_DWORD_AT(DiskStat, JAZ_LAST_LBA_OFFSET);
|
||||||
} else {
|
} else {
|
||||||
if (DiskStat[0] == DISK_STATUS_PAGE) {
|
if (DiskStat[0] == DISK_STATUS_PAGE) {
|
||||||
eax = WORD_AT(DiskStat[NEW_ZIP_SIDE_0_SPARES_COUNT_OFFSET]);
|
eax = GET_WORD_AT( DiskStat, NEW_ZIP_SIDE_0_SPARES_COUNT_OFFSET);
|
||||||
ebx = WORD_AT(DiskStat[NEW_ZIP_SIDE_1_SPARES_COUNT_OFFSET]);
|
ebx = GET_WORD_AT( DiskStat, NEW_ZIP_SIDE_1_SPARES_COUNT_OFFSET);
|
||||||
cl = BYTE_AT(DiskStat[NEW_ZIP_PROTECT_MODE_OFFSET]);
|
cl = GET_BYTE_AT( DiskStat, NEW_ZIP_PROTECT_MODE_OFFSET);
|
||||||
edx = DWORD_AT(DiskStat[NEW_ZIP_LAST_LBA_OFFSET]);
|
edx = GET_DWORD_AT( DiskStat, NEW_ZIP_LAST_LBA_OFFSET);
|
||||||
ch--; // set the DRIVE_A_SUPPORT
|
ch--; // set the DRIVE_A_SUPPORT
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
eax = WORD_AT(DiskStat[OLD_ZIP_SIDE_0_SPARES_COUNT_OFFSET]);
|
eax = GET_WORD_AT( DiskStat, OLD_ZIP_SIDE_0_SPARES_COUNT_OFFSET);
|
||||||
ebx = WORD_AT(DiskStat[OLD_ZIP_SIDE_1_SPARES_COUNT_OFFSET]);
|
ebx = GET_WORD_AT( DiskStat, OLD_ZIP_SIDE_1_SPARES_COUNT_OFFSET);
|
||||||
cl = BYTE_AT(DiskStat[OLD_ZIP_PROTECT_MODE_OFFSET]);
|
cl = GET_BYTE_AT( DiskStat, OLD_ZIP_PROTECT_MODE_OFFSET);
|
||||||
edx = DWORD_AT(DiskStat[OLD_ZIP_LAST_LBA_OFFSET]);
|
edx = GET_DWORD_AT( DiskStat, OLD_ZIP_LAST_LBA_OFFSET);
|
||||||
}
|
}
|
||||||
if(ebx == 0) {
|
if(ebx == 0) {
|
||||||
goto NoSpares;
|
goto NoSpares;
|
||||||
|
@ -411,7 +429,7 @@ long GetSpareSectorCounts(bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// MLT: The code for removing the ZIP protection has been omitted
|
// MLT: The code for removing the ZIP protection has been omitted
|
||||||
return 0; // return zero since no error
|
return 0; // return zero since no erro
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// trouble of some sort ... so suppress controls and
|
// trouble of some sort ... so suppress controls and
|
||||||
|
@ -470,7 +488,7 @@ void SetCartridgeStatusToEAX(long eax) {
|
||||||
CartridgeStatus = eax;
|
CartridgeStatus = eax;
|
||||||
|
|
||||||
// Set the text of the "action initiate button"
|
// Set the text of the "action initiate button"
|
||||||
const char *esi;
|
const char *esi = 0;
|
||||||
switch (CartridgeStatus) {
|
switch (CartridgeStatus) {
|
||||||
case DISK_SPUN_DOWN:
|
case DISK_SPUN_DOWN:
|
||||||
// set the button to "Start Disk Spinning"
|
// set the button to "Start Disk Spinning"
|
||||||
|
@ -516,6 +534,7 @@ void SetCartridgeStatusToEAX(long eax) {
|
||||||
// The disk *IS* at speed so enable the action button!
|
// The disk *IS* at speed so enable the action button!
|
||||||
EnableTestBtn:
|
EnableTestBtn:
|
||||||
EnableWindow(hTestButton, true);
|
EnableWindow(hTestButton, true);
|
||||||
|
esi = szPressToStart;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// set the button to "One Moment Please"
|
// set the button to "One Moment Please"
|
||||||
|
@ -613,8 +632,8 @@ long PerformRegionTransfer(short XferCmd, void *pBuffer) {
|
||||||
SetErrorRecovery(false, false, true); // disable Retries & ECC
|
SetErrorRecovery(false, false, true); // disable Retries & ECC
|
||||||
|
|
||||||
Scsi[0] = XferCmd;
|
Scsi[0] = XferCmd;
|
||||||
DWORD_AT(Scsi[2]) = MAKE_BIG_ENDIAN(FirstLBASector); // WHICH LBA's to read, BIG endian
|
SET_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
|
SET_WORD_AT (Scsi, 7, MAKE_BIG_ENDIAN(NumberOfLBAs)); // HOW MANY to read, BIG endian
|
||||||
long eax = SCSICommand(CurrentDevice, Scsi, pBuffer, NumberOfLBAs * BYTES_PER_SECTOR);
|
long eax = SCSICommand(CurrentDevice, Scsi, pBuffer, NumberOfLBAs * BYTES_PER_SECTOR);
|
||||||
// if we failed somewhere during our transfer ... let's zero in on it
|
// if we failed somewhere during our transfer ... let's zero in on it
|
||||||
if (eax) {
|
if (eax) {
|
||||||
|
@ -646,8 +665,8 @@ long PerformRegionTransfer(short XferCmd, void *pBuffer) {
|
||||||
|
|
||||||
memset(Scsi, 0, sizeof(Scsi)); // clear out the SCSI CDB
|
memset(Scsi, 0, sizeof(Scsi)); // clear out the SCSI CDB
|
||||||
Scsi[0] = XferCmd;
|
Scsi[0] = XferCmd;
|
||||||
DWORD_AT(Scsi[2]) = MAKE_BIG_ENDIAN(SingleTransferLBA); // WHICH LBA to read, BIG endian
|
SET_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
|
SET_WORD_AT (Scsi, 7, MAKE_BIG_ENDIAN(1)); // a single sector
|
||||||
eax = SCSICommand(CurrentDevice, Scsi, LocalBuffer, BYTES_PER_SECTOR);
|
eax = SCSICommand(CurrentDevice, Scsi, LocalBuffer, BYTES_PER_SECTOR);
|
||||||
|
|
||||||
if (eax) {
|
if (eax) {
|
||||||
|
@ -767,7 +786,7 @@ long TestTheDisk() {
|
||||||
|
|
||||||
// get a random pattern of data to write
|
// get a random pattern of data to write
|
||||||
const long DataPattern = rand();
|
const long DataPattern = rand();
|
||||||
memset(pPatternBuffer, DataPattern, sizeof(pPatternBuffer));
|
memset(pPatternBuffer, DataPattern, MAX_SECTORS_PER_TEST * BYTES_PER_SECTOR);
|
||||||
|
|
||||||
// update the cartridge's status
|
// update the cartridge's status
|
||||||
GetSpareSectorCounts(false); // update the Cart's Condition
|
GetSpareSectorCounts(false); // update the Cart's Condition
|
||||||
|
|
|
@ -52,15 +52,16 @@ void NewTipWindow() {
|
||||||
AllowColor = theWorld.hasColorQD;
|
AllowColor = theWorld.hasColorQD;
|
||||||
|
|
||||||
Rect rect = qd.screenBits.bounds;
|
Rect rect = qd.screenBits.bounds;
|
||||||
InsetRect(&rect, 50, 50);
|
rect.left = 7;
|
||||||
|
rect.top = 43;
|
||||||
rect.bottom = rect.top + 336 - 35;
|
rect.bottom = rect.top + 336 - 35;
|
||||||
rect.right = rect.left + 467;
|
rect.right = rect.left + 467;
|
||||||
|
|
||||||
Str255 title;
|
Str255 title;
|
||||||
StrToPascal(title, szWindowTitle);
|
StrToPascal(title, szWindowTitle);
|
||||||
tipWindow = AllowColor ?
|
tipWindow = AllowColor ?
|
||||||
NewCWindow(NULL,&rect, title, true, 0, 0, true, 0) :
|
NewCWindow(NULL,&rect, title, true, 0, (WindowPtr)-1, true, 0) :
|
||||||
NewWindow(NULL,&rect, title, true, 0, 0, true, 0);
|
NewWindow(NULL,&rect, title, true, 0, (WindowPtr)-1, true, 0);
|
||||||
|
|
||||||
GetDC(hMainWnd);
|
GetDC(hMainWnd);
|
||||||
|
|
||||||
|
@ -365,7 +366,7 @@ void SetWindowText(int id, const char *str) {
|
||||||
* ENABLE WINDOW
|
* ENABLE WINDOW
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
void EnableWindow(int id, bool enabled) {
|
void EnableWindow(int id, bool enabled) {
|
||||||
ControlHandle hCntl;
|
ControlHandle hCntl = 0;
|
||||||
if(id == hTestButton) hCntl = testBtn;
|
if(id == hTestButton) hCntl = testBtn;
|
||||||
if(id == hExitButton) hCntl = exitBtn;
|
if(id == hExitButton) hCntl = exitBtn;
|
||||||
if(hCntl) {
|
if(hCntl) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user