Flash Tool 1.2 doesn't work under System 3.2 - it bombs with error ID = 12, which seems to mean I called a trap routine that's not implemented in that version of the system. I fixed one instance of this by changing the program to use GetNextEvent() instead of WaitNextEvent(), so now at least the program starts up and shows the dialog box. But if you select a file to use as the ROM image, it bombs again with ID = 12, and I can't figure out why.
From experiments with commenting out parts of the code, it looks like calls to FSOpen() and GetDialogItem() both cause an ID = 12 bomb. But FSOpen() appears in Inside Macintosh Volume II, which means it's been available since the earliest days of the Mac. I don't know why it would bomb. GetDialogItem() is a renamed version of GetDItem(), which appears in Inside Macintosh Volume I. Again, it's been there since forever, and shouldn't bomb under old System versions.
Here is the code where the bombs occur when running under System 3.2, inside the if (repl.good) block:
void SelectFile()
{
SFReply repl;
Point where;
short itemType;
Handle itemHandle;
Rect itemRect;
short fileRefNum;
OSErr err = noErr;
where.h = 100;
where.v = 100;
SFGetFile(where,"\pROM image file:",0L,-1,0L,0L,&repl);
if (repl.good)
{
if (FSOpen(repl.fName, repl.vRefNum, &fileRefNum) != noErr)
{
ParamText("\pError opening image file", NULL, NULL, NULL);
NoteAlert(ALERT_ID, NULL);
return;
}
err = GetEOF(fileRefNum, &imageFileSize);
FSClose(fileRefNum);
if (err != noErr)
{
ParamText("\pError determining size of image file", NULL, NULL, NULL);
NoteAlert(ALERT_ID, NULL);
return;
}
imageFileVRefNum = repl.vRefNum;
GetDialogItem(dg, DIALOG_ITEM_FILENAME, &itemType, &itemHandle, &itemRect);
SetDialogItemText(itemHandle, repl.fName);
sprintf(imageFileSizeText, "%lu bytes (%lX hex)", imageFileSize, imageFileSize);
c2pstr(imageFileSizeText);
GetDialogItem(dg, DIALOG_ITEM_FILESIZE, &itemType, &itemHandle, &itemRect);
SetDialogItemText(itemHandle, (unsigned char*)imageFileSizeText);
}
}
(aside - is there no way to retain text formatting when making forum posts here?)
Any ideas why System 3.2 would choke on this code, and how to fix it?
|