mirror of
https://github.com/antoinevignau/source.git
synced 2025-01-20 02:30:40 +00:00
1 line
5.6 KiB
C
1 line
5.6 KiB
C
#include <gsos.h>
|
|
#include <quickdraw.h>
|
|
#include <qdaux.h>
|
|
#include <window.h>
|
|
#include <MiscTool.h>
|
|
#include <texttool.h>
|
|
#include <malloc.h>
|
|
#include "scan.h"
|
|
/* include the following line to use Tool039
|
|
* #include "scToolSet.h"
|
|
*/
|
|
char test[80];
|
|
|
|
#if 0
|
|
|
|
/**********************************************************************/
|
|
|
|
void pdlWait()
|
|
{
|
|
unsigned int i;
|
|
|
|
for (;;) {
|
|
GrafOff();
|
|
for (;;) {
|
|
for (i = 2; i; i--) {
|
|
if (*((char *)(0xE0C060 + i)) & 0x80) break;
|
|
}
|
|
if (i) break;
|
|
}
|
|
GrafOn();
|
|
for (; *((char *)(0xE0C060 + i)) & 0x80;) {
|
|
if (*((char *)(0xE0C063 - i)) & 0x80) return;
|
|
}
|
|
if (i == 1) return;
|
|
}
|
|
}
|
|
|
|
/**********************************************************************/
|
|
|
|
void sbug(str)
|
|
char *str;
|
|
{
|
|
if (*((char *)0xE0C061) >= 0x80) return;
|
|
InitTextDev(1);
|
|
WriteCString(str);
|
|
pdlWait();
|
|
}
|
|
|
|
/**********************************************************************/
|
|
|
|
void stack()
|
|
{
|
|
unsigned int stk;
|
|
|
|
asm {
|
|
tsc
|
|
sta stk
|
|
}
|
|
sprintf(test, "stack=%X", stk);
|
|
sbug(test);
|
|
}
|
|
|
|
#endif
|
|
|
|
asm (SwapBytes) {
|
|
lda 4,s
|
|
xba
|
|
rtl
|
|
}
|
|
|
|
asm (SwapWords) {
|
|
lda 4,s /* swap the words, and swap the bytes inside of those words */
|
|
xba
|
|
tax
|
|
lda 6,s
|
|
xba
|
|
rtl
|
|
}
|
|
|
|
/*********************************************************************************************/
|
|
|
|
long doScan(bufferHandle, bufferSize, sWindowDef, Width, Length)
|
|
Handle bufferHandle;
|
|
unsigned long bufferSize, Width, Length;
|
|
scannerWindowDef *sWindowDef;
|
|
{
|
|
extern Long (*Setup[])();
|
|
unsigned long requestCount, transferCount;
|
|
|
|
Scanner_Open();
|
|
|
|
transferCount = (*Setup[Scanner_Type])(bufferHandle, bufferSize, sWindowDef, Width, Length);
|
|
|
|
Scanner_Close();
|
|
return(transferCount);
|
|
}
|
|
|
|
long Setup_Apple(bufferHandle, bufferSize, sWindowDef, Width, Length)
|
|
Handle bufferHandle;
|
|
unsigned long bufferSize, Width, Length;
|
|
scannerWindowDef *sWindowDef;
|
|
{
|
|
unsigned long requestCount, transferCount;
|
|
Scanner_SetMode();
|
|
Scanner_SetHalfTones();
|
|
Scanner_DefWindow(sWindowDef);
|
|
Scanner_Scan();
|
|
|
|
transferCount = Scanner_Read(*bufferHandle, bufferSize);
|
|
|
|
return(transferCount);
|
|
}
|
|
|
|
long Setup_CPCScan(bufferHandle, bufferSize, sWindowDef, Width, Length)
|
|
Handle bufferHandle;
|
|
unsigned long bufferSize, Width, Length;
|
|
scannerWindowDef *sWindowDef;
|
|
{
|
|
unsigned long requestCount, transferCount;
|
|
|
|
transferCount = CPC_Scan(*bufferHandle, bufferSize, Width, Length);
|
|
|
|
return(transferCount);
|
|
}
|
|
|
|
#ifndef __scToolSet__ /* original version */
|
|
int findScanner()
|
|
{
|
|
int retcode = 1; /* assume we're gonna find a scanner */
|
|
char cmdData[16]; /* need 16 bytes for Command Data list */
|
|
ResultBuf32 devName;
|
|
DInfoRecGS devInfo;
|
|
DAccessRecGS devStatus;
|
|
extern int scanDevnum;
|
|
|
|
devInfo.pCount = 8; /* we need the device ID */
|
|
devInfo.devNum = 1; /* start at the first device */
|
|
devInfo.devName = &devName;
|
|
devName.bufSize = 36;
|
|
|
|
scanDevnum = 0; /* initialize scanner device number */
|
|
|
|
DInfoGS(&devInfo); /* make the call */
|
|
while(!_toolErr) { /* continue until we run out of devices */
|
|
if(devInfo.deviceID == 0x001a) { /* is this a SCSI scanner? */
|
|
scanDevnum = devInfo.devNum; /* yes, save the device number */
|
|
break; /* and exit */
|
|
}
|
|
++devInfo.devNum; /* check the next device */
|
|
DInfoGS(&devInfo);
|
|
}
|
|
if(_toolErr && (_toolErr != 0x11)) {
|
|
InitCursor();
|
|
ErrorWindow(0,NULL,_toolErr);
|
|
WaitCursor();
|
|
}
|
|
|
|
if(!scanDevnum) {
|
|
InitCursor();
|
|
retcode = AlertWindow(4, NULL, (long) noScannerFound);
|
|
WaitCursor();
|
|
} else { /* we have a scanner DIB, let's make sure it's ready for us */
|
|
devStatus.pCount = 5; /* set up for DStatus call */
|
|
devStatus.devNum = scanDevnum;
|
|
devStatus.code = 0x8000; /* TestUnitReady status call */
|
|
devStatus.list = (Ptr) cmdData;
|
|
memset(cmdData,0,16); /* set to all zeros */
|
|
devStatus.requestCount = 0; /* not used for this call */
|
|
DStatusGS(&devStatus);
|
|
while(_toolErr) { /* if we get an error, let the user know */
|
|
InitCursor();
|
|
retcode = AlertWindow(4, NULL, (long) scannerNotReady);
|
|
WaitCursor();
|
|
if(!retcode) /* user clicked QUIT */
|
|
break;
|
|
else if(retcode == 2) { /* user clicked "Continue" */
|
|
scanDevnum = 0; /* pretend we didn't find a scanner */
|
|
break;
|
|
} else { /* user clicked on "Try Again" */
|
|
DStatusGS(&devStatus); /* do the status call again */
|
|
DStatusGS(&devStatus); /* and again to make sure the SCSI bus is initialized */
|
|
}
|
|
}
|
|
}
|
|
|
|
return(retcode);
|
|
}
|
|
|
|
#else /* new version which uses the toolset */
|
|
int findScanner()
|
|
{
|
|
int retcode = 1; /* assume we're gonna find a scanner */
|
|
extern int scanDevnum;
|
|
|
|
scanDevnum = 0; /* initialize scanner device number */
|
|
|
|
/* start up the toolset here */
|
|
scStartUp();
|
|
|
|
switch(_toolErr) {
|
|
case 0: /* no error */
|
|
scanDevnum = scGetDevNum(); /* get the device number from the toolset */
|
|
break;
|
|
|
|
case scNotFoundErr:
|
|
InitCursor();
|
|
retcode = AlertWindow(4, NULL, (long) noScannerFound);
|
|
WaitCursor();
|
|
break;
|
|
|
|
case scScannerErr:
|
|
while(_toolErr) { /* if we get an error, let the user know */
|
|
InitCursor();
|
|
retcode = AlertWindow(4, NULL, (long) scannerNotReady);
|
|
WaitCursor();
|
|
if(!retcode) /* user clicked QUIT */
|
|
break;
|
|
else if(retcode == 2) { /* user clicked "Continue" */
|
|
scanDevnum = 0; /* pretend we didn't find a scanner */
|
|
break;
|
|
} else { /* user clicked on "Try Again" */
|
|
scStartUp(); /* so try to start up the toolset again */
|
|
}
|
|
}
|
|
break;
|
|
|
|
default:
|
|
InitCursor();
|
|
ErrorWindow(0,NULL,_toolErr);
|
|
WaitCursor();
|
|
}
|
|
|
|
return(retcode);
|
|
}
|
|
|
|
#endif
|
|
|
|
void testPause()
|
|
{
|
|
|
|
SysBeep(); SysBeep();
|
|
while (*(char *) 0xe0c000 < 128)
|
|
;
|
|
*(char *) 0xe0c010 = 0;
|
|
}
|
|
|