diff --git a/scsi2/AppleScanGS/AppleScan.GS b/scsi2/AppleScanGS/AppleScan.GS new file mode 100644 index 0000000..e4d9212 Binary files /dev/null and b/scsi2/AppleScanGS/AppleScan.GS differ diff --git a/scsi2/AppleScanGS/AppleScan.GS_ResourceFork.bin b/scsi2/AppleScanGS/AppleScan.GS_ResourceFork.bin new file mode 100644 index 0000000..ab18107 Binary files /dev/null and b/scsi2/AppleScanGS/AppleScan.GS_ResourceFork.bin differ diff --git a/scsi2/AppleScanGS/BoxCtrl..oc.aii b/scsi2/AppleScanGS/BoxCtrl..oc.aii new file mode 100644 index 0000000..ad7834c --- /dev/null +++ b/scsi2/AppleScanGS/BoxCtrl..oc.aii @@ -0,0 +1 @@ + case obj case on PRINT PUSH,OFF INCLUDE 'BoxCtrl.DefProc.mac' PRINT POP ******************************************************************************* * BoxCtl CDEFProc * * (C) Copyright Apple Computer, Inc. 1988 * All rights reserved. * * by Keith Rollin * September 1, 1988 * * This is a Custom Control for the Apple IIGS. It is similar in appearance * and action to the 'resize' box you get when clicking on an object in GS Draw * or MacDraw. * * The Control is essentially a frame with 4 or 8 grow knobs on the corners * and/or edges. Dragging on any of these knobs will grow the control. Dragging * on the frame will move the entire control (like moving a window). A flag can * be set so that the control will be dragged if the user clicks in the interior * of the control as well. Part codes for the knobs and frame are listed below. * * Snapping the rectangle's coordinates to a grid is also supported. The * rectangle is snapped to the nearest point on the grid. This effectively means * that I perform rounding, and not truncating. * * The frame of the control is the rectangle passed to NewControl. The size of * the knobs and the size of the grid are passed in ctlValue. The 'interior drag * flag' is passed in ctlFlags. See below for details. * * Color is supported. Currently, only two colors are used: one for the frame, * and one for the knobs. The default colors are black. * * * * * Modification History: * * v1.0a1 02-Apr-88 kaar New Today * v1.0a2 04-Apr-88 kaar Changed part codes. Defined CtlData to point * to a data block. Added edge knobs. Grid can * now be rectangular. Knob rectangles no longer * part of control (created on the fly). Added * new flags to ctlFlag. CtlValue now contains * only the size of the knobs. * v1.0a3 07-Apr-88 kaar Removed dependance on Direct Page from the * application (now uses the stack). Responds to * Hilite(255). * V1.0a4 08-Apr-88 kaar Added support for when Param1/2 are null. * V1.0B1 23-Apr-88 kaar Fixed some bugs. Checked for gridsizes of 0 * and 1. Called InvalRect in DragCtl. * V2.0B2 08-Jun-88 kaar Cleaned up the code some in response to a * code review. Version number bumped to 2.0 to * reflect existance of simpler 1.0 version for * a technote. Added support for fCtlTie in the * owner window's frame flags. Improved perfor- * mance and legibility of Snap2Grid routine. * V2.0B3 08-Jul-88 kaar Part codes changed again. It seems that only * one indicator per control is allowed. Turned * the source code upside down and put it into * Steve Glass format. Implemented some of Dan's * programming style suggestions. * V2.0 01-Sep-88 kaar First Release * * V2.01 23-May-90 Greg Branche * * Added minHeight and minWidth parameters to allow the * application to define the minimum width and height of * the control. This was formerly handled by the minX * and minY parameters. These have been redefined so * that they specify the leftmost and uppermost limits * of the control. The maxX and maxY parameters specify * the right- and bottom-most limits. * * Bug fixes: * * 1) In myDrawCtl, the code was never working * right that checked the current state of the * control to determine whether to draw the control * as active or inactive. This has been modified * to use a flag passed in the high word of ctlParam * as the state indicator. $0000 = control is active, * $FFFF = control is inactive. * * Version 1.0 kaar * * Used in Custom Control technote * * * Version 2.0 kaar * * Release for Source Code Demo Disk #1 * * * Version 2.01 Greg Branche * * Used for AppleScan.GS * ******************************************************************************* * * Part Code returned: * * $A0 for all parts of the control (all parts are 'indicators') * * * CtlValue: Bits 8-15: width of grow knobs * Bits 0- 7: height of grow knobs * * CtlFlag bits: * 7 = 1 - Control is invisible * = 0 - Control is visible * 2 = 1 - Has edge knobs * = 0 - Doesn't * 1 = 1 - Has corner knobs * = 0 - Doesn't * 0 = 1 - Clicking in interior will drag control * = 0 - Clicking in interior does nothing * * Data: Contains a pointer to the following data block. This data * block holds the following information, which is copied to * the end of the control record: * * WORD: Min Y when growing (top limit) * WORD: Min X when growing (left limit) * WORD: Max Y when growing (bottom limit) * WORD: Max X when growing (right limit) * WORD: Min Height * WORD: Min Width * WORD: Spacing for Y segment of grid * WORD: Spacing for X segment of grid * * Color Table: * WORD: Bits 12-15: * 8-11: Knob Color * 4- 7: Inactive Frame/Knob Color * 0- 3: Frame Color * ******************************************************************************* * * How to use the Control: * * Initialization and tracking of the control work just like any other; * set it up with NewControl. When GetNextEvent returns inContent, call * FindControl to see if you hit the control. If you did, call * TrackControl. * * Initialization: * * pha ; space for result * pha * PushLong theWindow * PushLong #theRect ; pointer to bounding rectangle * PushLong #0 ; no title * PushWord #%00000111 ; vis, int will drag, corners & edges * PushWord #$0503 ; Width = 5/Height = 3 * PushLong #CtrlData ; Pointer to additional data * PushLong #BoxProc ; pointer to DefProc * PushLong #0 ; refcon * PushLong #0 ; use std color table * _NewControl * PullLong theControl * * theRect dc.w 50,140,110,300 * CtrlData dc.w 10 ; min Y * dc.w 10 ; min X * dc.w 100 ; max Y * dc.w 200 ; max X * dc.w 10 ; min height * dc.w 16 ; min width * dc.w 16 ; grid Y * dc.w 32 ; grid X * ******************************************************************************* ********************************************************************** * * * Apple IIGS Source Code Sampler, Volume I * * * * Copyright (c) Apple Computer, Inc. 1988 * * All Rights Reserved * * * * Written by Apple II Developer Tech Support * * * * * * * * ---------------------------------------------------------------- * * * * This program and its derivatives are licensed only for * * use on Apple computers. * * * * Works based on this program must contain and * * conspicuously display this notice. * * * * This software is provided for your evaluation and to * * assist you in developing software for the Apple IIGS * * computer. * * * * DISCLAIMER OF WARRANTY * * * * THE SOFTWARE IS PROVIDED "AS IS" WITHOUT * * WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, * * WITH RESPECT TO ITS MERCHANTABILITY OR ITS FITNESS * * FOR ANY PARTICULAR PURPOSE. THE ENTIRE RISK AS TO * * THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH * * YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU (AND * * NOT APPLE OR AN APPLE AUTHORIZED REPRESENTATIVE) * * ASSUME THE ENTIRE COST OF ALL NECESSARY SERVICING, * * REPAIR OR CORRECTION. * * * * Apple does not warrant that the functions * * contained in the Software will meet your requirements * * or that the operation of the Software will be * * uninterrupted or error free or that defects in the * * Software will be corrected. * * * * SOME STATES DO NOT ALLOW THE EXCLUSION * * OF IMPLIED WARRANTIES, SO THE ABOVE EXCLUSION MAY * * NOT APPLY TO YOU. THIS WARRANTY GIVES YOU SPECIFIC * * LEGAL RIGHTS AND YOU MAY ALSO HAVE OTHER RIGHTS * * WHICH VARY FROM STATE TO STATE. * * * * * ********************************************************************** eject ;------------------------------------------- ; ; --- Constants ; ; --- Stack Frame/Local Direct Page usage ; OrigD equ 1 ; caller's saved direct page register OrigB equ OrigD+2 ; caller's saved data bank register work equ OrigB+1 ; general use work space CtlPtr equ work+4 ; pointer to control record RtnAddr equ CtlPtr+4 ; RTL address back to Control Manager theCtlHandle equ RtnAddr+3 ; handle to control record CtlParam equ theCtlHandle+4 ; add'l parameter passed to DefProc CtlCode equ CtlParam+4 ; operation to perform ReturnValue equ CtlCode+2 ; space for return value to Ctl Mgr. ; ; --- Offsets for my control record ; oCtlMinY equ octlColor+4 oCtlMinX equ oCtlMinY+2 oCtlMaxY equ oCtlMinX+2 oCtlMaxX equ oCtlMaxY+2 oCtlMinHeight equ oCtlMaxX+2 oCtlMinWidth equ oCtlMinHeight+2 oCtlGridY equ oCtlMinWidth+2 oCtlGridX equ oCtlGridY+2 oCtlSize equ oCtlGridX+2 ; ; --- Part codes for my control ; BoxCtlPart equ $A0 ; This is returned to the app. FramePart equ $01 ; These are used internally to tell InteriorPart equ $02 ; 'myDragCtl' what part of the ULPart equ $03 ; control we are dragging. TopPart equ $04 URPart equ $05 RightPart equ $06 LLPart equ $07 BottomPart equ $08 LRPart equ $09 LeftPart equ $0A ; ; --- Masks for ctlFlags ; dragIntMask equ %00000001 ; if set, let user drag on interior knobCornerMask equ %00000010 ; if set, draw knobs on the corners knobEdgeMask equ %00000100 ; if set, draw knobs on the edges visMask equ ctlInVis EJECT ******************************************************************************* * CtlData RECORD * * Description: Storage for CDEF * * * External Refs: NONE * * Entry Points: NONE * ******************************************************************************* deltaX ds.b 2 ; used when growing the control deltaY ds.b 2 ColorPtr ds.b 4 ; pointer to actual color table to use theParam ds.b 4 ; copy of CtlParam passed on stack dragPart ds.b 2 ; internal part of control hit myCtlRect ds.b 8 ; copy of CtlRect in control record myCtlGridY ds.b 2 ; copy of CtlGridY myCtlGridX ds.b 2 ; copy of CtlGridX FrameHeight ds.b 2 FrameWidth ds.b 2 knobUL ds.b 8 ; This space is used to store the knobTop ds.b 8 ; rectangles that define the grow knobUR ds.b 8 ; knobs on the control. They are knobRight ds.b 8 ; created as needed, and are not knobLR ds.b 8 ; stored in the control record. knobBottom ds.b 8 knobLL ds.b 8 knobLeft ds.b 8 StdColorTable dc.b $C0 ; grey inact frame, blk normal frame dc.b $00 ; black knobs StdCtlData dc.w 10,10,200,640,0,0 ; min 10,10; max 200,640; no grid oldPenState ds.b $32 ; storage for old pen state. GreyPattern dc.b $CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC dc.b $CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC dc.b $CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC dc.b $CC,$CC,$CC,$CC,$CC,$CC,$CC,$CC ENDR EJECT ******************************************************************************* * BoxProc PROC Export * * Description: Main Routine for Custom Control. * * * Inputs: On entry, the parameters are passed to us on the stack. * * | | Previous Contents * |-------------------| * | ReturnValue | LONG - Space for return value * |-------------------| * | CtlCode | WORD - operation to perform * |-------------------| * | CtlParam | LONG - add'l parameter * |-------------------| * | theCtlHandle | LONG - Handle to control record * |-------------------| * | RtnAddr | 3 BYTES - RTL address * |-------------------| * | | <-- Stack pointer * * Outputs: Put something into ReturnValue, pull off the parameters, * and return to the Control Manager. * * | | Previous Contents * |-------------------| * | ReturnValue | LONG - Space for return value * |-------------------| * | RtnAddr | 3 BYTES - RTL address * |-------------------| * | | <-- Stack pointer * * External Refs: import InitCtlData import myDrawCtl import myTestCtl import myInitCtl import myDragCtl import myNewValue import mySetParams import myRecSize import Null * * Entry Points: NONE * ******************************************************************************* with CtlData ; ; We are going to be using the stack as our direct page for the ; custom control. The equates listed at the beginning of the custom ; control (right after the pageful of comments that explain it) ; describe the layout of the stack frame. ; ; The way we set up the stack frame as our direct page is by first ; saving the old contents of the DP register, transfering the stack ; pointer to the accumulator, and then transferring that to the DP ; register. We also save the contents of the Data Bank Register and ; reset it to the Program Bank Register so that we don't have to ; use 3-byte long addressing anywhere. We will restore both of these ; registers when we leave the custom control. ; pha ; push on some room for 'CtlPtr' pha pha ; push on some room for 'work' pha phb ; save the Data Bank register phd ; save the Direct Page register phk ; switch data bank to program bank plb tsc ; switch Direct Page into stack tcd jsr InitCtlData ; init some handy data lda GridSize/2 then ; coordinate := coordinate + GridSize ; ldy #6 ; init our loop index Loop sty YSave lda whichGridYX ; do we now use X or Y grid spacing? and #%0001 beq UseY lda myCtlGridX bra UseIt UseY lda myCtlGridY ; we now have the gridsize in the Acc UseIt cmp #2 ; Is it 0 or 1? If so, then skip over blt ShortCircuit ; dividing routine. sta GridSize ; save this for the divide later. pha ; push space on stack for the result pha ; of the divide we are going to do. lda [>16 pea |&addr[2:255] ELSEIF &addr[1:1]='[' THEN ldy #&offset+2 pushword &addr,y ldy #&offset pushword &addr,y ELSEIF &offset='s' THEN pushword &addr+2,s pushword &addr+2,s ELSEIF &offset='' THEN pushword &addr+2 pushword &addr ELSE pushword &addr+2,&offset pushword &addr,&offset ENDIF MEND ;............................................................... ; ; Push 2 bytes onto stack ; ; pushword loc -- pushes bytes onto stack from 'loc' ; pushword loc,x -- pushes bytes onto stack from 'loc,x' ; pushword #n -- pushes constant #n onto stack ; pushword -- pushes bytes onto stack (from A) ;............................................................... MACRO pushword &addr,® IF &addr[1:1]='#' AND &SETTING('LONGA')='ON' THEN pea |&addr[2:255] ELSE IF &addr­'' THEN IF ®­'' THEN lda &addr,® ELSE lda &addr ENDIF ENDIF pha ENDIF MEND ;............................................................... ; ; Pull 2 bytes from stack ; ; pullword loc -- pulls bytes off stack and stores in 'loc' ; pullword loc,x -- pulls bytes off stack and stores in 'loc,x' ; pullword -- pulls bytes off stack and leaves in A ;............................................................... MACRO pullword &addr,® pla IF &addr­'' THEN IF ®­'' THEN sta &addr,® ELSE sta &addr ENDIF ELSEIF ®­'' THEN AERROR 'Illegal 2nd parameter' ENDIF MEND ; from M16.Window MACRO &lab _InvalRect &lab ldx #$3A0E jsl $E10000 MEND * * my own custom macros * ; cmps - signed comparison ; use just like the cmp instruction, but destroys contents of accumulator ; conditions c and z flags just like the built in cmp instruction. ; MACRO cmps &oprnd ; signed comparison sec sbc &oprnd beq @1 bvs @2 if &Setting('LONGA')='OFF' then ; must determine correct operand size eor #$80 else eor #$8000 endif @2 bmi @greaterThan clc dc.b $B0 ; BCS opcode @greaterThan sec @1 ENDM \ No newline at end of file diff --git a/scsi2/AppleScanGS/Control.c b/scsi2/AppleScanGS/Control.c new file mode 100644 index 0000000..358b1c4 --- /dev/null +++ b/scsi2/AppleScanGS/Control.c @@ -0,0 +1 @@ +/********************************************************************** * * Control.c * * Copyright (c) 1990 * Apple Computer, Inc. * All Rights Reserved. * * This file contains the code which implements the * procedures for the various controls. * **********************************************************************/ #define rulerXoffset 0 #define rulerYoffset 0 #define previewRes 75 #define maxX 10200 #define maxY 16800 #define yOrg 10 #define xOrg 36 #include #include #include #include #include #include #include #include #include #include #include #include #include #include "Scan.h" #include "Scanner_GSOS.h" extern scannerWindowDef sWindowDef; extern GrafPortPtr previewWindowPtr; extern void updateScannerWindow(); extern void updatePreviewWindow(); /* called by TrackControl when the mouse is held down in one of the scroll controls */ pascal void scrollAction(partCode,ctrlHndl) int partCode; Handle ctrlHndl; { int currentValue; if(partCode) { /* only do the work if the part code is valid */ currentValue = GetCtlValue(ctrlHndl); /* get the current value */ switch(partCode) { /* which part is active? */ case downArrow: /* right arrow */ if(++currentValue > 255) /* make sure we stay within the value bounds */ currentValue = 255; break; case upArrow: /* left arrow */ if(--currentValue < 0) currentValue = 0; break; case pageDown: /* right paging region */ if((currentValue += 8) > 255) currentValue = 255; break; case pageUp: /* left paging region */ if((currentValue -= 8) < 0) currentValue = 0; break; } SetCtlValue(currentValue, ctrlHndl); } return; } word getResolutionPopUp(theControlHandle) Handle theControlHandle; { static int resTable[] = {0, 75, 100, 150, 200, 300}; return(resTable[GetCtlValue(theControlHandle)]); } long doGetXYPos( xStart,xEnd,yStart,yEnd) unsigned long *xStart,*xEnd,*yStart,*yEnd; { CtlRecPtr boxCtl; Rect *boxRect; unsigned i; unsigned long temp, deltaX; if(!previewWindowPtr) { /* if preview window has not been opened... */ *xStart = *yStart = 0; /* use default values to define page */ *xEnd = 10200; /* 1200 * 8.5 inches */ *yEnd = 13200; /* 1200 * 11 inches */ } else { boxCtl = *GetWControls(previewWindowPtr); /* get the control handle from the window record */ boxRect = &(boxCtl->ctlRect); /* make a pointer to the control's rect */ *xStart = ((long) (boxRect->h1 - XINSET) * 1200) / hPPI; *xEnd = ((long) (boxRect->h2 - XINSET) * 1200) / hPPI; *yStart = ((long) (boxRect->v1 - YINSET) * 1200) / vPPI; *yEnd = ((long) (boxRect->v2 - YINSET) * 1200) / vPPI; } if(*yEnd < *yStart) { /* make sure that y is in the increasing direction */ temp = *yEnd; *yEnd = *yStart; *yStart = temp; } if(*xEnd < *xStart){ /* make sure that x is in the increasing direction */ temp = *xEnd; *xEnd = *xStart; *xStart = temp; } return (*yEnd - *yStart); /* scanlength */ } long doFixXPos( xStart,xEnd,yStart,yEnd,xres) unsigned long *xStart,*xEnd,*yStart,*yEnd; word xres; { unsigned long chunkiness, fixAmount; unsigned long remainder, diff, deltaX; diff = (Long)(*xEnd - *xStart); chunkiness = 8*xres; deltaX = diff%chunkiness; fixAmount = chunkiness - deltaX; if(deltaX != 0) { if(*xEnd + fixAmount > maxX) { if(fixAmount >= *xStart) { *xStart = 0; *xEnd = maxX; } else { *xStart -= fixAmount; } } else { *xEnd += fixAmount; } } return(*xEnd - *xStart); /* return scanWidth */ } doGetBrightness() { return(GetCtlValue(GetCtlHandleFromID(NULL,BrightnessScroll))); } doGetContrast() { return(GetCtlValue(GetCtlHandleFromID(NULL,ContrastScroll))); } doGetThreshold() { return(GetCtlValue(GetCtlHandleFromID(NULL,ThresholdScroll))); } doGetImageComposition() { return(GetCtlValue(GetCtlHandleFromID(NULL,CompositionPopUp))-1); } doGetBitsPerPixel(scanType) byte scanType; { byte dpi; switch(scanType){ case 0: dpi = 1; break; case 1: dpi = 1; break; case 2: dpi = 4; break; } return(dpi); } #if 0 /* currently not used, but will be when Data Chaining is implemented */ static void invertImage(bufptr, buflen) unsigned *bufptr; long buflen; /* number of 16-bit words in buffer */ { GrafPortPtr theWindow, oldPort; char *statText; unsigned cursNum = 0; unsigned counter = 0; word oldSCB; int thermX, thermY; int chunkSize, chunkCount; static Rect thermRect = {50,10,60,229}; statText = "Now inverting the image"; /* remember the current GrafPort */ oldPort = GetPort(); /* draw the thermometer window */ theWindow = NewWindow2(NULL,NULL,NULL,NULL,2,ThermWindow,0x800E); SetPort(theWindow); MoveTo((240 - CStringWidth(statText)) >> 1 ,30); DrawCString(statText); FrameRect(&thermRect); /* draw the thermometer frame */ SetSolidPenPat(7); /* use a red pen */ thermX = 11; thermY = 51; /* init drawing locations */ chunkSize = buflen / 217; /* determine size to process before filling in a line */ chunkCount = 0; SetMasterSCB((oldSCB = GetMasterSCB()) | 0x0100); /* make sure cursor doesn't flicker */ do { *bufptr ^= 0xffff; ++bufptr; if(!(++counter & 0x1fff)) { SetCursor(animCursor[++cursNum]); if(!(cursNum < 7)) /* in other words, if cursNum >= 7 (but this produces better code) */ cursNum = -1; } if(++chunkCount == chunkSize) { MoveTo(thermX++, thermY); /* init the pen position */ Line(0,7); chunkCount = 0; } } while(--buflen); SetMasterSCB(oldSCB); /* reset master SCB */ SetPort(oldPort); /* reset the GrafPort */ CloseWindow(theWindow); /* close the alert window */ SetSolidPenPat(0); /* reset the pen back to black */ } #endif void doScanButton() { unsigned *tempPtr; Handle bufferHandle; unsigned long bufferSize, i, transferCount; word xGSres, yGSres; unsigned long scanLength,scanWidth; unsigned long xStart,xEnd,yStart,yEnd; unsigned long dataWidth, dataLength; extern long doScan(); sWindowDef.windDescBlockLenMSB = 0; sWindowDef.windDescBlockLenLSB = 0x28; sWindowDef.windowIdentifier = 0; xGSres = getResolutionPopUp(GetCtlHandleFromID(NULL,XResolutionPopUp)); yGSres = getResolutionPopUp(GetCtlHandleFromID(NULL,YResolutionPopUp)); sWindowDef.xResolution = SwapBytes(xGSres); /* we want the # of 1200ths of an inch in lsb>>msb */ sWindowDef.yResolution = SwapBytes(yGSres); scanLength = doGetXYPos(&xStart,&xEnd,&yStart,&yEnd); scanWidth = doFixXPos(&xStart,&xEnd,&yStart,&yEnd,xGSres); sWindowDef.xUpperLeft = SwapWords(xStart); sWindowDef.yUpperLeft = SwapWords(yStart); sWindowDef.width = SwapWords(scanWidth); sWindowDef.length = SwapWords(scanLength); sWindowDef.brightness = doGetBrightness(); sWindowDef.threshold = doGetThreshold(); sWindowDef.contrast = doGetContrast(); sWindowDef.imageComposition = doGetImageComposition(); sWindowDef.bitsPerPixel = doGetBitsPerPixel(sWindowDef.imageComposition); sWindowDef.halfTone = SwapBytes(2); sWindowDef.paddingType = 3; switch(xGSres){ case 75: scanWidth += 16; break; case 150: scanWidth += 8; break; } dataWidth = (((scanWidth*xGSres)/1200) * (long) (sWindowDef.bitsPerPixel))/8; /* in bytes */ dataLength = (scanLength*yGSres)/1200; /* # of scan lines */ bufferSize = dataWidth * dataLength; /* bytes per scan line * # of scan lines */ bufferHandle = NewHandle(bufferSize,_ownerid,attrFixed,NULL); if(_toolErr != 0) { AlertWindow(4,NULL,(long) noMemAvailable); } else { WaitCursor(); transferCount = doScan(bufferHandle, bufferSize, &sWindowDef, dataWidth, dataLength); doOpenImage(dataWidth, dataLength, bufferHandle); InitCursor(); } } void doPreviewButton(){ /* format_call(); eject_call(); set_confg_parms(); set_format(); Assign_part(); arm_signal(); disarm_signal(); set_part_map(); reserve_unit(); release_unit(); send_diagnostics(); return_dev_status(); return_confg_parms(); return_wait(); return_format(); return_part_map(); return_last_cmd(); test_unit_rdy(); request_sense(); inquiry(); mode_sense(); get_wndow_parms(); extended_read(); get_data_status(); if(_toolErr != 0) { AlertWindow(4,NULL,(long) noMemAvailable); } */ } \ No newline at end of file diff --git a/scsi2/AppleScanGS/Event.c b/scsi2/AppleScanGS/Event.c new file mode 100644 index 0000000..fe37ba2 --- /dev/null +++ b/scsi2/AppleScanGS/Event.c @@ -0,0 +1 @@ +/********************************************************************** * * Event.c * * Copyright (c) * Apple Computer, Inc. 1986-1989 * All Rights Reserved. * * This file contains the code which implements the * main event loop used by the scanner program. * **********************************************************************/ #include #include #include #include #include #include #include "Scan.h" extern WmTaskRec event; extern unsigned int quitFlag; extern GrafPortPtr previewWindowPtr; extern GrafPortPtr settingsWindowPtr; static GrafPortPtr lastWindow; /* This private global is used in checkFrontW() ** to prevent extra work when the windows ** have not changed. It is initialized ** at the beginning of mainEvent(). */ /********************************************************************** * * doSetPageScroll * * This procedure is called when an inGrow or inZoom message is returned * by TaskMaster. * * This procedure resets the values used to scroll the content region * when the page areas are clicked on in the scroll bars. * ***********************************************************************/ static void doSetPageScroll() { int tempH, tempV; tempV = lastWindow->portRect.v2-lastWindow->portRect.v1; /* calculate vertical size */ tempH = lastWindow->portRect.h2-lastWindow->portRect.h1; /* calculate width */ SetPage(tempH-10, tempV-10, lastWindow); } /********************************************************************** * * doControls * * This procedure is called when an inControl message is returned * by TaskMaster. * * When this routine gets control, the ID of the control that was * hit is in TaskDATA4. The control handle is in TaskData2 and * the part code is in taskData 3. * **********************************************************************/ void doControls() { LongWord theID, thePartCode; LongWord theControlHandle; theID = event.wmTaskData4; thePartCode = event.wmTaskData3; theControlHandle = event.wmTaskData2; if (( 0 <= theID) && (theID <= 0xFFFFFFFF )) { switch(theID) { case ScanButton: doScanButton(); break; case PreviewButton: doPreviewButton(); break; } } } /********************************************************************** * * doInContent * * This procedure is called when an InContent message is returned * by TaskMaster. * * When this routine gets control, the ID of the control that was * hit is in TaskDATA4. The control handle is in TaskData2 and * the part code is in taskData 3. * **********************************************************************/ void doInContent() { LongWord theID, thePartCode; LongWord theControlHandle; theID = event.wmTaskData4; thePartCode = event.wmTaskData3; theControlHandle = event.wmTaskData2; SelectWindow(event.wmTaskData); #if 0 if (event.what == 0x01) { /* was it a mouse down event? */ if ((GrafPortPtr) event.wmTaskData == previewWindowPtr){ doInPreview(event.where); } } #endif } /********************************************************************** * * checkFrontW * * This routine checks the front window to see if any changes need * to be made to the menu items. * * We do this so that the edit items are only active when a desk * accessory is active. * **********************************************************************/ void checkFrontW() { GrafPortPtr theWindow; extern int cTable[], defCTable[]; theWindow = FrontWindow(); /* Get the front window into local storage.*/ if (theWindow == lastWindow) return; /* If the lastWindow is this window, we are all set. */ /* If there are no windows, everything should be disabled */ if (!theWindow) { SetMenuFlag(0x0080, EditMenuID); HiliteMenu(0,EditMenuID); SetColorTable(0,defCTable); } /* if the front window is an image window, then we want to enable the edit items */ if (!( (theWindow == previewWindowPtr)||(theWindow == settingsWindowPtr))) { EnableMItem(SaveAsID); /* allow Save As... */ SetMenuFlag (0xFF7F, EditMenuID); /* Set up for da windows. */ HiliteMenu(0,EditMenuID); } else { DisableMItem(SaveAsID); /* don't allow saving */ /* Otherwise we look at the window and see what to do. */ if (GetSysWFlag(theWindow)) { SetMenuFlag (0xFF7F, EditMenuID); /* Set up for da windows. */ HiliteMenu(0,EditMenuID); } else { SetMenuFlag (0x0080, EditMenuID); /* Set up for our windows. */ HiliteMenu(0,EditMenuID); } } /* use grayscale pallette for Preview or Image windows */ if((theWindow != settingsWindowPtr) && !GetSysWFlag(theWindow)) SetColorTable(0,cTable); else SetColorTable(0,defCTable); lastWindow = theWindow; /* Remember this for next time. */ /* here we want to update the hor/vert text if need be */ } /********************************************************************** * * mainEvent * * This is the main part of the program. The program cycles in this * loop until the user choose select. * **********************************************************************/ void mainEvent() { unsigned int code; unsigned temp; event.wmTaskMask = 0x001FFF7F; /* Allow TaskMaster to do everything, and return inContents */ quitFlag = 0; /* Done flag will be set by Quit item. */ lastWindow = NULL; /* Init this for checkFrontW(). */ for (;;) { checkFrontW(); code = TaskMaster(0xFFFF, &event); switch(code) { case wNoHit: /* null event, but TaskMaster might have handled something */ temp = event.wmTaskData & 0xffff; /* get the event code */ if(temp == wInGrow || temp == wInZoom) /* if the window changed sizes */ doSetPageScroll(); break; case wInGoAway: doCloseTop(); break; case wInSpecial: case wInMenuBar: doMenu(); break; case wInControl: doControls(); break; case wInContent: doInContent(); break; } if (quitFlag) break; } } \ No newline at end of file diff --git a/scsi2/AppleScanGS/Globals.c b/scsi2/AppleScanGS/Globals.c new file mode 100644 index 0000000..8af1f08 --- /dev/null +++ b/scsi2/AppleScanGS/Globals.c @@ -0,0 +1 @@ +/*********************************************************************** * * Globals.c * * Copyright (c) * Apple Computer, Inc. 1986-1989 * All Rights Reserved. * * This file contains the code which intializes the global variables * used by the scanner program. * ***********************************************************************/ #include "Scan.h" #include #include #include unsigned int quitFlag = 0; /* True when quitting */ unsigned int staggerCount = 0; /* Used to stagger windows as they open */ WmTaskRec event; /* All events are returned here */ scannerWindowDef sWindowDef; GrafPortPtr previewWindowPtr = NULL; GrafPortPtr settingsWindowPtr = NULL; PicHndl previewRuler = NULL; int scanDevnum; /* device number of Scanner */ word Scanner_Type; long (*Setup[2])() = {Setup_Apple,Setup_CPCScan}; void initGlobals() { quitFlag = staggerCount = 0; sWindowDef.reserved0 = sWindowDef.reserved0 = sWindowDef.reserved1 = sWindowDef.reserved2 = 0; sWindowDef.reserved3 = sWindowDef.reserved4 = sWindowDef.reserved5 = 0; sWindowDef.windDescBlockLenMSB = sWindowDef.windDescBlockLenLSB = 0; sWindowDef.windowIdentifier = sWindowDef.reserved6 = sWindowDef.xResolution = 0; sWindowDef.yResolution = sWindowDef.xUpperLeft = sWindowDef.yUpperLeft = 0; sWindowDef.width = sWindowDef.length = sWindowDef.brightness = 0; sWindowDef.threshold = sWindowDef.contrast = sWindowDef.imageComposition = 0; sWindowDef.bitsPerPixel = sWindowDef.halfTone = sWindowDef.paddingType = 0; } \ No newline at end of file diff --git a/scsi2/AppleScanGS/Makefile b/scsi2/AppleScanGS/Makefile new file mode 100644 index 0000000..b2cf1a7 --- /dev/null +++ b/scsi2/AppleScanGS/Makefile @@ -0,0 +1 @@ +# File: makefile # Target: AppleScan.GS # Created: Tuesday, August 29, 1989 10:46:51 AM Objs = Scan.obj ¶ Event.obj ¶ Globals.obj ¶ Menu.obj ¶ Utils.obj ¶ Window.obj ¶ Control.obj ¶ xSaveFile.obj ¶ Scanner_gsos.obj ¶ BoxCtrl.DefProc.obj AppleScan.GS ÄÄ Scan.r ScannerDefs.h "{RIIGSIncludes}"TypesIIGS.r RezIIGS Scan.r -o AppleScan.GS AppleScan.GS ÄÄ "{CIIGSLibrary}"Start.obj {objs} LinkIIGS -l >AppleScan.map -at $0000DB03 ¶ "{CIIGSLibrary}"BankAlign.obj # used only during debugging ¶ "{CIIGSLibrary}"Start.obj ¶ {objs} ¶ -lib "{CIIGSLibrary}"CLib ¶ -o AppleScan.GS ¶ -w2 # warnings are treated as fatal errors .obj Ä .c CIIGS {default}.c -o {default}.obj .obj Ä .aii ASMIIGS {default}.aii -o {default}.obj # include file dependencies Scan.h Ä "{CIIGSIncludes}"Types.h ¶ ScannerDefs.h SetFile -m . Scan.h Control.obj Ä "{CIIGSIncludes}"control.h ¶ "{CIIGSIncludes}"intmath.h ¶ "{CIIGSIncludes}"types.h ¶ "{CIIGSIncludes}"list.h ¶ "{CIIGSIncludes}"locator.h ¶ "{CIIGSIncludes}"quickdraw.h ¶ "{CIIGSIncludes}"qdaux.h ¶ "{CIIGSIncludes}"event.h ¶ "{CIIGSIncludes}"lineEdit.h ¶ "{CIIGSIncludes}"menu.h ¶ "{CIIGSIncludes}"memory.h ¶ "{CIIGSIncludes}"resources.h ¶ "{CIIGSIncludes}"window.h ¶ Scan.h ¶ Scanner_GSOS.h Event.obj Ä "{CIIGSIncludes}"types.h ¶ "{CIIGSIncludes}"locator.h ¶ "{CIIGSIncludes}"quickdraw.h ¶ "{CIIGSIncludes}"event.h ¶ "{CIIGSIncludes}"menu.h ¶ "{CIIGSIncludes}"window.h ¶ Scan.h Globals.obj Ä Scan.h ¶ "{CIIGSIncludes}"qdaux.h ¶ "{CIIGSIncludes}"quickdraw.h ¶ "{CIIGSIncludes}"window.h Menu.obj Ä "{CIIGSIncludes}"control.h ¶ "{CIIGSIncludes}"types.h ¶ "{CIIGSIncludes}"quickdraw.h ¶ "{CIIGSIncludes}"qdaux.h ¶ "{CIIGSIncludes}"window.h ¶ "{CIIGSIncludes}"event.h ¶ "{CIIGSIncludes}"menu.h ¶ "{CIIGSIncludes}"desk.h ¶ "{CIIGSIncludes}"intmath.h ¶ "{CIIGSIncludes}"stdfile.h ¶ "{CIIGSIncludes}"gsos.h ¶ "{CIIGSIncludes}"memory.h ¶ "{CIIGSIncludes}"malloc.h ¶ Scan.h ¶ Scan.obj Ä "{CIIGSIncludes}"types.h ¶ "{CIIGSIncludes}"quickdraw.h ¶ "{CIIGSIncludes}"locator.h ¶ "{CIIGSIncludes}"TextTool.h ¶ "{CIIGSIncludes}"IntMath.h Utils.obj Ä "{CIIGSIncludes}"quickdraw.h ¶ "{CIIGSIncludes}"QDAux.h ¶ "{CIIGSIncludes}"GSOS.h ¶ "{CIIGSIncludes}"Window.h ¶ "{CIIGSIncludes}"MiscTool.h ¶ "{CIIGSIncludes}"texttool.h ¶ Scan.h Window.obj Ä "{CIIGSIncludes}"intmath.h ¶ "{CIIGSIncludes}"memory.h ¶ "{CIIGSIncludes}"types.h ¶ "{CIIGSIncludes}"quickdraw.h ¶ "{CIIGSIncludes}"qdaux.h ¶ "{CIIGSIncludes}"resources.h ¶ "{CIIGSIncludes}"window.h ¶ "{CIIGSIncludes}"misctool.h ¶ "{CIIGSIncludes}"control.h ¶ "{CIIGSIncludes}"menu.h ¶ "{CIIGSIncludes}"malloc.h ¶ Scan.h xSaveFile.obj Ä "{CIIGSIncludes}"gsos.h ¶ "{CIIGSIncludes}"memory.h ¶ "{CIIGSIncludes}"malloc.h ¶ "{CIIGSIncludes}"string.h ¶ "{CIIGSIncludes}"quickdraw.h ¶ "{CIIGSIncludes}"qdaux.h ¶ "{CIIGSIncludes}"misctool.h BoxCtrl.DefProc.obj Ä BoxCtrl.DefProc.mac \ No newline at end of file diff --git a/scsi2/AppleScanGS/Menu.c b/scsi2/AppleScanGS/Menu.c new file mode 100644 index 0000000..7a90a19 --- /dev/null +++ b/scsi2/AppleScanGS/Menu.c @@ -0,0 +1 @@ +/*********************************************************************** * * Menu.c * * Copyright (c) * Apple Computer, Inc. 1986-1989 * All Rights Reserved. * * This file contains the code which implements * menus in the scanner program. * ***********************************************************************/ #include #include #include #include #include #include #include #include #include #include #include #include #include #include "Scan.h" extern WmTaskRec event; extern unsigned int quitFlag; extern GrafPortPtr previewWindow; extern GrafPortPtr settingsWindowPtr; extern GrafPortPtr openThisWindow(); SFReplyRec2 MyReply; extern void doCloseTop(); void doQuitItem(); void doAboutBox(); void doOpenItem(); void doSaveItem(); void doSaveAsItem(); void doPrefItem(); void doSettingsItem(); void doPreviewItem(); /* array of procedure address to handle menu selections */ void (*menuProc[])() = { doAboutBox, /* for Undo */ doAboutBox, /* for Cut */ doAboutBox, /* for Copy */ doAboutBox, /* for Paste */ doAboutBox, /* for Clear */ doCloseTop, /* for Close */ doAboutBox, /* for About (really!) */ doOpenItem, /* for Open */ doSaveItem, /* for Save */ doSaveAsItem, /* for Save As */ doPrefItem, /* for Preferences */ doAboutBox, /* for Print */ doQuitItem, /* for Quit */ doSettingsItem, /* for Settings (in Scan menu) */ doPreviewItem /* for Preview (in Scan Menu) */ }; /**********************************************************************/ void doQuitItem() { quitFlag++; } /**********************************************************************/ void doAboutBox() { AlertWindow(4, NULL, (long) AboutBox); } /**********************************************************************/ void doOpenItem() { AlertWindow(4, NULL, (long) AboutBox); } /**********************************************************************/ /**********************************************************************/ void doSaveItem() { AlertWindow(4, NULL, (long) AboutBox); } /**********************************************************************/ /**********************************************************************/ void doSaveAsItem() { extern int SavePic(); LocInfoHndl AuxHandle; LocInfoPtr RefPtr; ResultBuf255Ptr filename; GrafPortPtr WhichWindow; GSString255Ptr oldfilename; char *windowName, **nameHndl; int i, error; RefPtr = (LocInfoPtr) GetWRefCon((WhichWindow = FrontWindow())); nameHndl = (char **) GetWTitle(WhichWindow); /* get the current window title */ if((unsigned long) nameHndl & 0x80000000) { /* returned as a handle? */ windowName = *nameHndl; /* yes, dereference it */ nameHndl = NULL; /* then clear it so we don't dispose of it later */ } else windowName = (char *) nameHndl; /* else must be a real pointer */ oldfilename = (GSString255Ptr) malloc(*windowName+2); /* convert to GSOS string */ memcpy(oldfilename->text, windowName+2, (oldfilename->length = *windowName-2)); MyReply.nameDesc = MyReply.nameDesc = 3; /* let StdFile allocate the memory for the names */ SFPutFile2 (25,30, 0,"\pSave picture as:", 0, oldfilename, &MyReply); if (MyReply.good) { /* <> 0 --> OK to save it */ filename = (ResultBuf255Ptr) *((ResultBuf255Ptr *) MyReply.pathRef); if(error = /* assignment */ SavePic(&(filename->bufString), RefPtr)) /* save the picture */ ErrorWindow(0,NULL,error); else { filename = * ((ResultBuf255Ptr *) MyReply.nameRef); /* get pointer to filename result */ windowName = malloc((i = filename->bufString.length)+3); /* get the buffer */ windowName[0] = i + 2; /* set the new length (pascal string) */ memcpy(windowName+2,filename->bufString.text,i); /* copy the new name in */ windowName[1] = windowName[i+2] = ' '; SetWTitle(windowName,WhichWindow); /* change the window name */ if(nameHndl) /* if name was returned as a pointer... */ free(nameHndl); /* then dispose of the old name */ } } DisposeHandle(MyReply.nameRef); DisposeHandle(MyReply.pathRef); free(oldfilename); } /**********************************************************************/ void doPrefItem() { AlertWindow(4, NULL, (long) AboutBox); } /**********************************************************************/ void doSettingsItem() { Pointer theArrayList[1]; static char subString[] = {"0000"}; CtlRecHndl ctlHandle; extern void scrollAction(); extern int scanDevnum; if(settingsWindowPtr == NULL) { settingsWindowPtr = openThisWindow(SettingsWindow); if(!scanDevnum) { /* if a scanner wasn't found during initialization */ HiliteControl(inactiveHilite, GetCtlHandleFromID(settingsWindowPtr,ScanButton)); /* disable the buttons */ HiliteControl(inactiveHilite, GetCtlHandleFromID(settingsWindowPtr,PreviewButton)); } EnableMItem(CloseID); SetCtlAction(scrollAction,GetCtlHandleFromID(NULL,BrightnessScroll)); SetCtlAction(scrollAction,GetCtlHandleFromID(NULL,ContrastScroll)); SetCtlAction(scrollAction,GetCtlHandleFromID(NULL,ThresholdScroll)); } else SelectWindow(settingsWindowPtr); } /**********************************************************************/ void doPreviewItem() { openPreview(); } /**********************************************************************/ void doMenu() { unsigned int menuNum, itemNum; unsigned int *intPtr; /* Procedure to handle all menu selections. Examines the event.TaskData ** menu item ID word from TaskMaster (from Event Manager) and calls the ** appropriate routine. While the routine is running the menu title is ** still highlighted. After the routine returns, we unhilight the ** menu title. */ intPtr = (unsigned *) &(event.wmTaskData); menuNum = intPtr[1]; /* get high word of TaskData */ /* menuNum = HiWord(event.wmTaskData); itemNum = LoWord(event.wmTaskData);*/ (*menuProc[*intPtr-250])(); /* call the menu handler */ HiliteMenu(0, menuNum); /* Unhighlight the menu title. */ } /**********************************************************************/ void setupMenus() { /* Procedure to install our menu titles and their items in the system menu ** bar and to redraw it so we can see them. */ SetSysBar(NewMenuBar2(refIsResource, 0x0001L, NULL)); SetMenuBar(NULL); FixAppleMenu(AppleMenuID); /* Add DAs to apple menu */ FixMenuBar(); /* Set sizes of menus */ DrawMenuBar(); /* ...and draw the menu bar! */ } \ No newline at end of file diff --git a/scsi2/AppleScanGS/Scan.c b/scsi2/AppleScanGS/Scan.c new file mode 100644 index 0000000..4eb5fd5 --- /dev/null +++ b/scsi2/AppleScanGS/Scan.c @@ -0,0 +1 @@ +/*********************************************************************** * * Scan.c (Main Program) * * Copyright (c) * Apple Computer, Inc. 1986-1989 * All Rights Reserved. * * This file contains the scanner program. * ***********************************************************************/ #include #include #include #include #include #include #include /* Include this line to use Tool039 (the Scanner Toolset) #include "scToolSet.h" */ main() { Ref initRef; /* This holds the reference to the startstop record */ char errBuf[5]; initGlobals(); /* Initialize our globals. */ TLStartUp(); /* start up the tool locator */ /* Startup the tools using the new toolbox call */ initRef = StartUpTools(_ownerid, refIsResource, 0x0001L); if (!_toolErr) { #ifdef __scToolSet__ LoadOneTool(39, 1); /* load the Scanner toolset */ if(_toolErr) { InitCursor(); ErrorWindow(0,NULL,_toolErr); WaitCursor(); } else if(findScanner()) { /* find the device number of the scanner */ #else if(findScanner()) { /* find the device number of the scanner */ #endif setupMenus(); /* Set up menus */ setupWindows(); InitCursor(); /* Make cursor show ready */ mainEvent(); /* Use application */ #ifdef __scToolSet__ scShutDown(); /* shut down the scanner toolset */ UnloadOneTool(39); #endif } ShutDownTools(refIsHandle, initRef); /* Let the toolbox shutdown the tools. */ } else { Int2Hex(_toolErr, &errBuf[1], 4); errBuf[0] = 4; WriteLine("\pUnable to start toolsets."); WriteCString("Error code = $"); WriteLine(errBuf); WriteLine("\pPress any key to quit..."); ReadChar(0); } TLShutDown(); /* qFlags = 0x4000; /* we can be restarted from memory */ } \ No newline at end of file diff --git a/scsi2/AppleScanGS/Scan.h b/scsi2/AppleScanGS/Scan.h new file mode 100644 index 0000000..9c30a37 --- /dev/null +++ b/scsi2/AppleScanGS/Scan.h @@ -0,0 +1 @@ +/*********************************************************************** * * Scan.h * * Copyright (c) 1990 * Apple Computer, Inc. * All Rights Reserved. * * This file contains the header data used by the scanner program. * ***********************************************************************/ #ifndef _scanner_ #define _scanner_ 1 #include extern Word SwapBytes(); extern Long SwapWords(); extern void testPause(); extern long Setup_Apple(),Setup_CPCScan(); extern Word Scanner_Type; typedef struct scannerWindowStruct { byte reserved0,reserved1,reserved2,reserved3,reserved4,reserved5; byte windDescBlockLenMSB,windDescBlockLenLSB; byte windowIdentifier; byte reserved6; word xResolution,yResolution; long xUpperLeft,yUpperLeft,width,length; byte brightness,threshold,contrast,imageComposition,bitsPerPixel; word halfTone; byte paddingType; byte reserved[10]; } scannerWindowDef; #define SHORTINDEX 123 #define AppWindow 0x1000 #include "ScannerDefs.h" struct cocoonMemRec { long itemRefID; byte listFlags; long windowID; }; typedef struct cocoonMemRec *cocoonMemRecPtr; /* constants used to define the box control */ #define XINSET 30 #define YINSET 20 #define XOFFSET 2 #define YOFFSET 2 #define hPPI 16 /* pixels per inch as displayed on screen rulers */ #define vPPI 10 #endif \ No newline at end of file diff --git a/scsi2/AppleScanGS/Scan.r b/scsi2/AppleScanGS/Scan.r new file mode 100644 index 0000000..3fe0f9d --- /dev/null +++ b/scsi2/AppleScanGS/Scan.r @@ -0,0 +1 @@ +/*---------------------------------------------------------------*/ #include "TypesIIGS.r" #include "ScannerDefs.h" /* tricky, tricky! */ /*------------------- Values used through out -------------------*/ #define LELine1 20 #define LELeft1 10 #define LEHeight 15 #define LEWidth 80 #define TopOfRow4 90 #define LeftEdge3 100 #define BottomOfRow4 110 #define RightEdge3 130 #define disabled $80 #ifndef fUseShadowing #define fUseShadowing $8000 #define fFastPortAware $4000 #endif /*----------------------- About Box ------------------------------*/ resource rAlertString (AboutBox) { "\$00\$19\$00\$0A\$00\$AA\$00\$35\$01" "\$00/" TBCenterJust TBStyleOutline "AppleScan.GS" TBEndOfLine TBEndOfLine TBStylePlain "A Program to digitize images using the Apple Scanner." TBEndOfLine TBEndOfLine "by" TBEndOfLine "The Apple ][" TBEndOfLine "System Software Group" TBEndOfLine TBEndOfLine "© 1990, Apple Computer, Inc." TBEndOfLine "All Rights Reserved" TBEndOfLine "Version 1.0d1/^#6\$00" }; /*----------------------- Unable to allocate handle ------------------------------*/ resource rAlertString (noMemAvailable) { "20|Unable to allocate Handle.|^#0" }; /*----------------- no scanner device found in device list ------------------------*/ resource rAlertString (noScannerFound) { "83|AppleScan.GS is unable to find a scanner. " "Please check the power and SCSI connections, and " "make sure you have the scanner driver file installed " "in your system folder." TBEndOfLine TBEndOfLine "If you continue, you can work with documents, but " "you will not be able to scan." TBEndOfLine "|^#5|#6\$00" }; /*----------------------- Unable to allocate handle ------------------------------*/ resource rAlertString (scannerNotReady) { "83|Your scanner is not ready to be used. Please " "make sure it's turned on and warmed up, then " "click on the \"Try Again\" button." TBEndOfLine TBEndOfLine "If you \"Continue\", you can work with documents, but " "you will not be able to scan." TBEndOfLine "|^#5|#4|#6\$00" }; /*----------------------Startup Record ---------------------------*/ resource rToolStartup (1) { fUseShadowing + fFastPortAware, /* master SCB, mode 320 */ { 3,$0100, /* misc tools */ 4,$0100, /* quickdraw */ 5,$0100, /* desk manager */ 6,$0100, /* eventMgr */ /* 7,$0100, /* scheduler */ /* 8,$0100, /* sound tools */ /* 9,$0100, /* ADB tools */ /* 10,$0100, /* SANE */ 11,$0100, /* int math */ 14,$0300, /* Window Manager */ 15,$0300, /* Menu Manager */ 16,$0300, /* Control Manager */ 18,$0200, /* QD Aux */ 19,$0100, /* print manager */ 20,$0100, /* LineEdit tool set */ 21,$0100, /* Dialog Manager */ 22,$0100, /* Scrap manager */ 23,$0100, /* standard file */ 27,$0100, /* Font manager */ 28,$0100, /* list manager */ 34,$0100, /* text edit */ /* 29,$0100, /* ACE */ /* 32,$0100, /* Midi Tools */ /* 25,$0100, /* NoteSynth */ /* 26,$0100 /* Note Seq */ } }; /*********************************************************************/ /* /* Menus /* /*********************************************************************/ resource rMenuBar (1) { { AppleMenuID, FileMenuID, EditMenuID, ScanMenuID, }; }; resource rMenu (ScanMenuID) { ScanMenuID, 0xA008, ScanMenuID, { SettingsID, PreviewID }; }; resource rMenu (AppleMenuID) { AppleMenuID, 0xA008, AppleMenuID, { AboutID }; }; resource rMenu (FileMenuID) { FileMenuID, 0xA008, FileMenuID, { OpenID, SaveID, SaveAsID, PrefID, PrintID, CloseID, QuitID }; }; resource rMenu (EditMenuID) { EditMenuID, 0xA088, EditMenuID, { UndoID, CutID, CopyID, PasteID, ClearID }; }; resource rMenuItem (PreviewID) { PreviewID, "","", //"T","t", 0, 0x8000, PreviewID }; resource rMenuItem (SettingsID) { SettingsID, "","", 0, 0x8000, SettingsID }; resource rMenuItem (AboutID) { AboutID, "","", 0, 0x8040, AboutID }; resource rMenuItem (UndoID) { UndoID, "Z","z", 0, 0x8080, UndoID }; resource rMenuItem (CutID) { CutID, "X","x", 0, 0x8080, CutID }; resource rMenuItem (CopyID) { CopyID, "C","c", 0, 0x8080, CopyID }; resource rMenuItem (PasteID) { PasteID, "V","v", 0, 0x8080, PasteID }; resource rMenuItem (ClearID) { ClearID, "","", 0, 0x8080, ClearID }; resource rMenuItem (CloseID) { CloseID, "W","w", 0, 0x8000+disabled, CloseID }; resource rMenuItem (QuitID) { QuitID, "Q","q", 0, 0x8000, QuitID }; resource rMenuItem (OpenID) { OpenID, "O","o", 0, 0x8000+disabled, OpenID }; resource rMenuItem (SaveID) { SaveID, "S","s", 0, 0x8000+disabled, SaveID }; resource rMenuItem (SaveAsID) { SaveAsID, "","", 0, 0x8000+disabled, SaveAsID }; resource rMenuItem (PrefID) { PrefID, "","", 0, 0x8000+disabled, PrefID }; resource rMenuItem (PrintID) { PrintID, "P","p", 0, 0x8000+disabled, PrintID }; resource rPString (AppleMenuID) { "@" }; resource rPString (FileMenuID) { " File " }; resource rPString (EditMenuID) { " Edit " }; resource rPString (ScanMenuID) { " Scan " }; resource rPString (AboutID) { "About AppleScan.GSÉ" }; resource rPString (CloseID) { "Close" }; resource rPString (UndoID) { "Undo" }; resource rPString (CutID) { "Cut" }; resource rPString (CopyID) { "Copy" }; resource rPString (PasteID) { "Paste" }; resource rPString (ClearID) { "Clear" }; resource rPString (QuitID) { "Quit" }; resource rPString (PreviewID) { "Preview" }; resource rPString (OpenID) { "Open" }; resource rPString (SaveID) { "Save" }; resource rPString (SaveAsID) { "Save AsÉ" }; resource rPString (PrefID) { "PreferencesÉ" }; resource rPString (PrintID) { "Print" }; resource rPString (SettingsID) { "SettingsÉ" }; /*---------------------------------------------------------------------------*/ /* /* ImageWindowÉ /* /*---------------------------------------------------------------------------*/ resource rWindParam1 (ImageWindow) { fTitle+fMove+fZoom+fGrow+fBScroll+fRScroll+fClose+fVis, /* Frame Bits */ ImageWindow, /* title ID */ 0, /* ref Con */ {0,0,0,0}, /* Zoom Rect */ ImageWindow, /* color table id */ {0,0}, /* origin */ {400,640}, /* data size */ {200,640}, /* max height-width */ {2,2}, /* scroll amount, hor,ver */ {60,200}, /* page amount */ 0, /* wInfo Ref Con */ 0, /* wInfo height */ {50,50,120,260}, /* window Position */ infront, /* wPlane */ 0, /* Control Ref */ (refIsResource<<8) + /* descriptor for title */ (refIsResource<<10) /* descriptor for color table */ }; resource rpString (ImageWindow) { "Image Window" }; resource rWindColor (ImageWindow) { $0000, /* frameColor */ $0f00, /* titleColor */ $020f, /* tBarColor */ $00f0, /* growColor */ $0000 /* infoColor (not used, for now) */ }; //--------------------------------------------------------------------------- // // Thermometer Window // //--------------------------------------------------------------------------- resource rWindParam1 (ThermWindow) { fAlert+fVis, /* Frame Bits */ NIL, /* title ID */ NIL, /* ref Con */ {0,0,0,0}, /* Zoom Rect */ NIL, /* color table id */ {0,0}, /* origin */ {0,0}, /* data size */ {0,0}, /* max height-width */ {0,0}, /* scroll amount, hor,ver */ {0,0}, /* page amount */ NIL, /* wInfo Ref Con */ NIL, /* wInfo height */ {30,40,99,279}, /* window Position */ infront, /* wPlane */ NIL, /* controlList */ refIsResource*0x0100 /* descriptor */ }; /*---------------------------------------------------------------------------*/ /* /* PreviewWindowÉ /* /*---------------------------------------------------------------------------*/ resource rWindParam1 (PreviewWindow) { fTitle+fMove+fVis+fClose, /* Frame Bits */ PreviewWindow, /* title ID */ 0, /* ref Con */ {0,0,0,0}, /* Zoom Rect */ 0, /* color table id */ {0,0}, /* origin */ {79,103}, /* data size */ {79,103}, /* max height-width */ {0,0}, /* scroll amount, hor,ver */ {0,0}, /* page amount */ 0, /* wInfo Ref Con */ 0, /* wInfo height */ {27,2,198,186}, /* window Position */ infront, /* wPlane */ PreviewWindow, /* Control Ref */ refIsResource*0x0100+resourceToResource /* descriptor */ }; resource rpString (PreviewWindow) { "Preview" }; resource rControlList (PreviewWindow) { { 0 }; }; /*---------------------------------------------------------------------------*/ /* /* SettingsWindowÉ /* /* The Settings window /* /*---------------------------------------------------------------------------*/ #define ObjectOffset (21) #define windowHeight (4*ObjectOffset)+10 // leave a little slop #define windowWidth (316) #define windowBorderSize ((320-windowWidth-2 /* for border */) / 2) #define windowTop (13 /* menu bar height */ + 13 /* window title bar height */ + windowBorderSize) #define windowLeft (windowBorderSize+1) #define windowBottom ((4*ObjectOffset)+10+windowTop) #define windowRight (320-windowLeft) #define LeftInset (2) #define RightInset (196+2) // 196 = window field separation point #define scanButtonWidth (68) #define previewButtonWidth (85) #define freeFieldWidth ((windowWidth-previewButtonWidth-scanButtonWidth)/3) #define scrollHeight (11) resource rWindParam1 (SettingsWindow) { fTitle+fMove+fVis+fClose, /* Frame Bits */ SettingsWindow, /* title ID */ 0, /* ref Con */ {0,0,0,0}, /* Zoom Rect */ 0, /* color table id */ {0,0}, /* origin */ {400,640}, /* data size */ {200,640}, /* max height-width */ {1,1}, /* scroll amount, hor,ver */ {10,10}, /* page amount */ 0, /* wInfo Ref Con */ 0, /* wInfo height */ {windowTop,windowLeft,windowBottom,windowRight}, /* window Position */ infront, /* wPlane */ SettingsWindow, /* Control Ref */ refIsResource*0x0100+resourceToResource /* descriptor */ }; resource rpString (SettingsWindow) { "Settings" }; resource rControlList (SettingsWindow) { { CompositionPopUp, XResolutionPopUp, YResolutionPopUp, BrightnessScroll, BrightnessStatText, ContrastScroll, ContrastStatText, ThresholdScroll, ThresholdStatText, ScanButton, PreviewButton, 0 }; }; /*------ Image Composition ------*/ resource rControlTemplate (CompositionPopUp) { CompositionPopUp, /* control ID */ {1,LeftInset,0,0}, /* control rectangle */ PopUpControl{{ /* control type */ 0, /* flags */ fctlProcNotPtr+RefIsResource, /* MoreFlags */ 0, /* RefCon */ 0, /* Title Width */ CompositionPopUp, /* Menu ref */ 3 /* Initial Value */ }} }; resource rMenu (CompositionPopUp) { CompositionPopUp, /* id of menu */ RefIsResource*MenuTitleRefShift+RefIsResource*ItemRefShift+fAllowCache, /* menu flags */ CompositionPopUp, /* id of title string */ { /* id's of items */ CompositionPopUpItem1, CompositionPopUpItem2, CompositionPopUpItem3 }; }; resource rPString (CompositionPopUp) { "Composition: " }; resource rMenuItem (CompositionPopUpItem1) { 1, "","", 0, 0x8000, CompositionPopUpItem1 }; resource rMenuItem (CompositionPopUpItem2) { 2, "","", 0, 0x8000, CompositionPopUpItem2 }; resource rMenuItem (CompositionPopUpItem3) { 3, "","", 0, 0x8000, CompositionPopUpItem3 }; resource rPString (CompositionPopUpItem1) { "Line Art" }; resource rPString (CompositionPopUpItem2) { "Halftone" }; resource rPString (CompositionPopUpItem3) { "Greyscale" }; /*------ XResolutionPopUp ------*/ resource rControlTemplate (XResolutionPopUp) { XResolutionPopUp, /* control ID */ {(1*ObjectOffset)+1,LeftInset,0,0}, /* control rectangle */ PopUpControl{{ /* control type */ 0, /* flags */ fctlProcNotPtr+RefIsResource, /* MoreFlags */ 0, /* RefCon */ 0, /* Title Width */ XResolutionPopUp, /* Menu ref */ 1 /* Initial Value */ }} }; resource rMenu (XResolutionPopUp) { XResolutionPopUp, /* id of menu */ RefIsResource*MenuTitleRefShift+RefIsResource*ItemRefShift+fAllowCache, /* menu flags */ XResolutionPopUp, /* id of title string */ { /* id's of items */ XResolutionPopUpItem1, XResolutionPopUpItem2, XResolutionPopUpItem3, XResolutionPopUpItem4, XResolutionPopUpItem5 }; }; resource rPString (XResolutionPopUp) { "X Resolution: " }; resource rMenuItem (XResolutionPopUpItem1) { 1, "","", 0, 0x8000, XResolutionPopUpItem1 }; resource rMenuItem (XResolutionPopUpItem2) { 2, "","", 0, 0x8000, XResolutionPopUpItem2 }; resource rMenuItem (XResolutionPopUpItem3) { 3, "","", 0, 0x8000, XResolutionPopUpItem3 }; resource rMenuItem (XResolutionPopUpItem4) { 4, "","", 0, 0x8000, XResolutionPopUpItem4 }; resource rMenuItem (XResolutionPopUpItem5) { 5, "","", 0, 0x8000, XResolutionPopUpItem5 }; resource rPString (XResolutionPopUpItem1) { "75 dpi" }; resource rPString (XResolutionPopUpItem2) { "100 dpi" }; resource rPString (XResolutionPopUpItem3) { "150 dpi" }; resource rPString (XResolutionPopUpItem4) { "200 dpi" }; resource rPString (XResolutionPopUpItem5) { "300 dpi" }; /*------ YResolutionPopUp ------*/ resource rControlTemplate (YResolutionPopUp) { YResolutionPopUp, /* control ID */ {(2*ObjectOffset)+1,LeftInset,0,0}, /* control rectangle */ PopUpControl{{ /* control type */ 0, /* flags */ fctlProcNotPtr+RefIsResource, /* MoreFlags */ 0, /* RefCon */ 0, /* Title Width */ YResolutionPopUp, /* Menu ref */ 1 /* Initial Value */ }} }; resource rMenu (YResolutionPopUp) { YResolutionPopUp, /* id of menu */ RefIsResource*MenuTitleRefShift+RefIsResource*ItemRefShift+fAllowCache, /* menu flags */ YResolutionPopUp, /* id of title string */ { /* id's of items */ YResolutionPopUpItem1, YResolutionPopUpItem2, YResolutionPopUpItem3, YResolutionPopUpItem4, YResolutionPopUpItem5 }; }; resource rPString (YResolutionPopUp) { "Y Resolution: " }; resource rMenuItem (YResolutionPopUpItem1) { 1, "","", 0, 0x8000, YResolutionPopUpItem1 }; resource rMenuItem (YResolutionPopUpItem2) { 2, "","", 0, 0x8000, YResolutionPopUpItem2 }; resource rMenuItem (YResolutionPopUpItem3) { 3, "","", 0, 0x8000, YResolutionPopUpItem3 }; resource rMenuItem (YResolutionPopUpItem4) { 4, "","", 0, 0x8000, YResolutionPopUpItem4 }; resource rMenuItem (YResolutionPopUpItem5) { 5, "","", 0, 0x8000, YResolutionPopUpItem5 }; resource rPString (YResolutionPopUpItem1) { "75 dpi" }; resource rPString (YResolutionPopUpItem2) { "100 dpi" }; resource rPString (YResolutionPopUpItem3) { "150 dpi" }; resource rPString (YResolutionPopUpItem4) { "200 dpi" }; resource rPString (YResolutionPopUpItem5) { "300 dpi" }; /*------ Preview Button ------*/ resource rControlTemplate (PreviewButton) { PreviewButton, /* control ID */ {3*ObjectOffset+10,freeFieldWidth,0,0}, /* control rect */ SimpleButtonControl{{ /* control type */ NormalButton, /* flag */ 0x3002, /* more flags */ 0, /* ref con */ PreviewButton, /* title ref */ 0 }} }; resource rpString (PreviewButton) { "Preview" }; /*------ Brightness Scroll Bar ------*/ #define horScroll $0010 #define rightFlag $0008 #define leftFlag $0004 resource rControlTemplate (BrightnessScroll) { BrightnessScroll, /* control ID */ {(0*ObjectOffset)+1,RightInset,(0*ObjectOffset)+1+scrollHeight,windowWidth-2}, /* control rect */ scrollControl{{ /* control type */ horScroll+rightFlag+leftFlag, /* flag */ FctlProcNotPtr, /* more flags */ 0, /* ref con */ 256, /* max size */ 1, /* view size */ 128 /* initial value */ }} }; resource rControlTemplate (BrightnessStatText) { BrightnessStatText, /* control ID */ {(0*ObjectOffset)+1+11,RightInset,(0*ObjectOffset)+21,windowWidth-2}, /* control rect */ StatTextControl{{ /* control type */ 0, /* flags */ FctlProcNotPtr+RefIsResource, /* more flags */ 0, /* refcon */ BrightnessStatText, /* textRef */ 0, /* textSize */ 1 /* justification (centered) */ }} }; resource rTextForLETextBox2 (BrightnessStatText) { "Brightness" }; /*------ Contrast Scroll Bar ------*/ resource rControlTemplate (ContrastScroll) { ContrastScroll, /* control ID */ {(1*ObjectOffset)+1,RightInset,(1*ObjectOffset)+1+scrollHeight,windowWidth-2}, /* control rect */ scrollControl{{ /* control type */ horScroll+rightFlag+leftFlag, /* flag */ FctlProcNotPtr, /* more flags */ 0, /* ref con */ 256, /* max size */ 1, /* view size */ 128 /* initial value */ }} }; resource rControlTemplate (ContrastStatText) { ContrastStatText, /* control ID */ {(1*ObjectOffset)+1+11,RightInset,(1*ObjectOffset)+21,windowWidth-2}, /* control rect */ StatTextControl{{ /* control type */ 0, /* flags */ FctlProcNotPtr+RefIsResource, /* more flags */ 0, /* refcon */ ContrastStatText, /* textRef */ 0, /* textSize */ 1 /* justification (centered) */ }} }; resource rTextForLETextBox2 (ContrastStatText) { "Contrast" }; /*------ Threshold Scroll Bar ------*/ resource rControlTemplate (ThresholdScroll) { ThresholdScroll, /* control ID */ {(2*ObjectOffset)+1,RightInset,(2*ObjectOffset)+1+scrollHeight,windowWidth-2}, /* control rect */ scrollControl{{ /* control type */ horScroll+rightFlag+leftFlag, /* flag */ FctlProcNotPtr, /* more flags */ 0, /* ref con */ 256, /* max size */ 1, /* view size */ 128 /* initial value */ }} }; resource rControlTemplate (ThresholdStatText) { ThresholdStatText, /* control ID */ {(2*ObjectOffset)+1+11,RightInset,(2*ObjectOffset)+21,windowWidth-2}, /* control rect */ StatTextControl{{ /* control type */ 0, /* flags */ FctlProcNotPtr+RefIsResource, /* more flags */ 0, /* refcon */ ThresholdStatText, /* textRef */ 0, /* textSize */ 1 /* justification (centered) */ }} }; resource rTextForLETextBox2 (ThresholdStatText) { "Threshold" }; /*------ Scan Button ------*/ resource rControlTemplate (ScanButton) { ScanButton, /* control ID */ {3*ObjectOffset+10,windowWidth-freeFieldWidth-scanButtonWidth,0,0}, /* control rect */ SimpleButtonControl{{ /* control type */ DefaultButton, /* flag */ 0x3002, /* more flags */ 0, /* ref con */ ScanButton, /* title ref */ 0, /* color table ref */ {"\n","\n",0,0} /* key equivalents (return and enter) */ }} }; resource rpString (ScanButton) { "Scan" }; \ No newline at end of file diff --git a/scsi2/AppleScanGS/Scanner.GSOS.aii b/scsi2/AppleScanGS/Scanner.GSOS.aii new file mode 100644 index 0000000..4d13e3b --- /dev/null +++ b/scsi2/AppleScanGS/Scanner.GSOS.aii @@ -0,0 +1 @@ + CASE OBJ Case On INCLUDE 'M16.UTIL' _useToolset equ 0 ; define as 1 to use Tool039 open_call equ $2010 read_call equ $2012 close_call equ $2014 dinfo_call equ $202c dstatus_call equ $202d dcontrol_call equ $202e Import scanDevnum Import _toolErr ;*********************************** ; Scanner_SetMode() ; description: This call sets the mode for scanning ; entry: None. ; exit: Carry set, and error code in Acc. ;*********************************** Scanner_SetMode PROC EXPORT if _useToolset then lda >scanDevnum sta >ms_did else ENTRY ms_did endif jsl $e100a8 ;normal GS/OS entry point dc.w dcontrol_call dc.l mode_select ;4 byte pointer to parameter block sta >_toolErr rtl mode_select dc.w $0005 ms_did dc.w $0000 dc.w $8015 dc.l @cdb dc.l $0000000C dc.l $00000000 @cdb dc.w $0000 dc.b $15 dc.b $10 dcb.b 2,$00 dc.b $0C dcb.b 7,$00 dc.l @data @data dcb.b 4,$00 ;reserved - 4 bytes dc.b $01 ;page code - Apple-specific parameter page dc.b $08 ;page length - Apple-specific page dc.b $01 ;graymap - 1 = no alteration to data dc.b $40 ;auto background adjustment threshold dc.b $00 ;lamp - 0 = turn off dcb.b 3,$00 ;reserved - 3 bytes ENDP ;*********************************** ; Scanner_SetHalfTones() ; description: This call sets the mode for scanning ; entry: None. ; exit: Carry set, and error code in Acc. ;*********************************** Scanner_SetHalfTones PROC EXPORT if _useToolset then lda >scanDevnum sta >send_did else ENTRY send_did endif jsl $e100a8 ;normal GS/OS entry point dc.w dcontrol_call dc.l send ;4 byte pointer to parameter block sta >_toolErr rtl send dc.w $0005 send_did dc.w $0000 dc.w $802A dc.l @cdb dc.l $00000011 dc.l $00000000 @cdb dc.w $0000 dc.b $2A dc.b $00 dc.b $02 dcb.b 2,$00 dc.b $02 dcb.b 2,$00 dc.b $11 dcb.b 3,$00 dc.l @data @data dc.b $44,$f0,$40,$80,$c0,$b0,$00,$10,$50 dc.b $70,$30,$20,$90,$e0,$a0,$60,$d0 ENDP ;*********************************** ; Scanner_DefWindow(scanner_window_definition) ; description: This call defines the scanner window ; entry: Long pointer to the scanner definition proc. ; exit: Carry set, and error code in Acc. ;*********************************** Scanner_DefWindow PROC EXPORT ENTRY dfw_did lda 6,S ;get the pointer to the window definition sta >def_data+2 lda 4,S ;get the rest of the pointer sta >def_data if _useToolset then lda >scanDevnum sta >dfw_did jsl $e100a8 ;normal GS/OS entry point else @over_2 jsl $e100a8 ;normal GS/OS entry point endif dc.w dcontrol_call dc.l def_wndw ;4 byte pointer to parameter block sta >_toolErr rtl def_wndw dc.w $0005 dfw_did dc.w $0000 dc.w $8024 dc.l @cdb dc.l $00000030 dc.l $00000000 @cdb dc.w $0000 dc.b $24 dcb.b 7,$00 dc.b $30 dc.b $80 dcb.b 2,$00 def_data dc.l $00000000 ENDP ;*********************************** ; Scanner_Scan() ; description: This call starts the scanner scanning ; entry: None. ; exit: Carry set, and error code in Acc. ;*********************************** Scanner_Scan PROC EXPORT if _useToolset then lda >scanDevnum sta >scan_did else ENTRY scan_did endif jsl $e100a8 ;normal GS/OS entry point dc.w dcontrol_call dc.l scan ;4 byte pointer to parameter block sta >_toolErr rtl scan dc.w $0005 scan_did dc.w $0000 dc.w $801B dc.l @cdb dc.l $00000001 dc.l $00000000 @cdb dc.w $0000 dc.b $1b dcb.b 3,$00 dc.b $01 dc.b $00 dcb.b 6,$00 dc.l @data @data dc.b $00 ENDP ;*********************************** ; Scanner_Read(data_pointer, requestCount) ; description: This call starts the scanner scanning ; entry: A pointer to the data destination, and a long count. ; exit: Carry set, and error code in Acc. ;NOTE: here we must utilize the pointer we are handed...., and it must reflect the real data size ;*********************************** Scanner_Read PROC EXPORT lda 6,S ;get the pointer to the window definition sta >buffer1+2 lda 4,S ;get the rest of the pointer sta >buffer1 lda 10,S ;get the data length sta >r_trans+2 lda 8,S ;get the rest of the data length sta >r_trans @save_loop jsl $e100a8 ;normal GS/OS entry point dc.w read_call dc.l read ;4 byte pointer to parameter block bcs @exit sta >_toolErr lda >t_trans+2 tax lda >t_trans rtl @exit sta >_toolErr rtl export r_dref read dc.w $0004 r_dref dc.w $0000 buffer1 dc.l $00000000 r_trans dc.l 300 t_trans dc.l $00000000 ENDP ;*********************************** ; CPCScan_SetMode() ; description: This call sets the mode for scanning on the ; Complete PC Scanner, both Hand and Page ; entry: None. ; exit: Carry set, and error code in Acc. ;*********************************** CPCScan_SetMode PROC EXPORT ENTRY CPCms_did jsl $e100a8 ;normal GS/OS entry point dc.w dcontrol_call dc.l @mode_select ;4 byte pointer to parameter block sta >_toolErr rtl @mode_select dc.w $0005 CPCms_did dc.w $0000 dc.w $8015 dc.l @cdb dc.l $0000000C dc.l $00000000 @cdb dc.w $0000 dc.b $15 dcb.b 3,$00 dc.b $0C dcb.b 7,$00 dc.l CPC_MSdata EXPORT CPC_MSdata CPC_MSdata dcb.b 4,$00 ;reserved - 4 bytes EXPORT CPC_Type CPC_Type dc.b $00 ;Scanner Type <128 = Hand, ł128 = Page dc.b $00 ;reserved EXPORT CPC_Page_Ctrl CPC_Page_Ctrl dc.b $00 ;Page Control 1=Go, 0 = Stop EXPORT CPC_Hand_Ctrl CPC_Hand_Ctrl dc.b $00 ;Hand Control 1=On, 0 = Off EXPORT CPC_Scan_Len CPC_Scan_Len dcb.b 2,$00 ;Bytes Per Line MSB >>> LSB CPC_Timer dcb.b 2,$00 ;ShutOff Timer MSB >>> LSB ENDP ;*********************************** ; CPCScan_GetMode() ; description: This call gets the mode for scanning on the ; Complete PC Scanner, both Hand and Page ; entry: None. ; exit: Carry set, and error code in Acc. ;*********************************** CPCScan_GetMode PROC EXPORT ENTRY CPCmsen_did IMPORT CPC_MSdata jsl $e100a8 ;normal GS/OS entry point dc.w dstatus_call dc.l @mode_sense ;4 byte pointer to parameter block sta >_toolErr rtl @mode_sense dc.w $0005 CPCmsen_did dc.w $0000 dc.w $801A dc.l @cdb dc.l $0000000C dc.l $00000000 @cdb dc.w $0000 dc.b $1A dcb.b 3,$00 dc.b $0C dcb.b 7,$00 dc.l CPC_MSdata ENDP ;*********************************** ; CPC_GDStatus() ; description: This call gets the data status ; entry: Long pointer to the scanner definition proc. ; exit: Carry set, and error code in Acc. ;*********************************** CPC_GDStatus PROC EXPORT ENTRY CPC_GDS_did jsl $e100a8 ;normal GS/OS entry point dc.w dstatus_call dc.l @gd_Status ;4 byte pointer to parameter block sta >_toolErr rtl @gd_Status dc.w $0005 CPC_GDS_did dc.w $0000 dc.w $8007 dc.l @cdb dc.l $00000004 dc.l $00000000 @cdb dc.w $0000 dc.b $07 dcb.b 3,$00 dc.b $04 dcb.b 7,$00 dc.l CPC_GDStat CPC_GDStat dc.b $00 ;Paper End Status for Page Scanner dc.b $00 ;Reserevd EXPORT CPC_Data CPC_Data dc.b $0000 ;Bytes Available MSB >>> LSB dcb.b $20,$00 ENDP ;*********************************** ; CPC_XSense() ; description: This call gets the Transfer Rate ; at the current scanner settings. ; ; For a Page Scanner: ; 113-137 $0071-$0089 = 300 DPI ; 75- 92 $004B-$005C = 200 DPI ; ; For a Hand Scanner: ; 85-103 $0055-$0067 = 400 DPI ; 63- 77 $003F-$004D = 300 DPI ; 42- 53 $002A-$0035 = 200 DPI ; ; entry: Long pointer to the scanner definition proc. ; exit: Carry set, and error code in Acc. ;*********************************** CPC_XSense PROC EXPORT ENTRY CPC_XS_did ; jsl $e100a8 ;normal GS/OS entry point ; dc.w dstatus_call ; dc.l @xd_Status ;4 byte pointer to parameter block ; sta >_toolErr rtl @xd_Status dc.w $0005 CPC_XS_did dc.w $0000 dc.w $800E dc.l @cdb dc.l $00000003 dc.l $00000000 @cdb dc.w $0000 dc.b $0E dcb.b 3,$00 dc.b $03 dcb.b 7,$00 dc.l CPC_XStatus CPC_XStatus dc.b $00 ;Will be a Two '2' EXPORT CPC_TRate CPC_TRate dc.w $0030 ;Transfer Rate MSB >>> LSB ENDP ;*********************************** ; CPC_Read() ; description: This call Reads the Scaned Data ; entry: None. ; exit: Carry set, and error code in Acc. ;*********************************** CPC_Read PROC EXPORT ENTRY CPCRead_did ENTRY CPC_ReadRqst ENTRY CPC_buffer1 jsl $e100a8 ;normal GS/OS entry point dc.w dstatus_call dc.l @read ;4 byte pointer to parameter block sta >_toolErr rtl @read dc.w $0005 CPCRead_did dc.w $0000 dc.w $8008 dc.l cdb CPC_ReadRqst dc.l $00000000 dc.l $00000000 cdb dc.w $0000 dc.b $08 dcb.b 2,$00 dc.w $0000 ;Becomes the Request Count in the Driver dcb.b 7,$00 CPC_buffer1 dc.l $00000000 ENDP ;*********************************** ; CPC_Unload() ; description: This call Stops the scanning Process ; entry: None. ; exit: Carry set, and error code in Acc. ;*********************************** CPC_Unload PROC EXPORT ENTRY CPC_Kill_did jsl $e100a8 ;normal GS/OS entry point dc.w dcontrol_call dc.l @unload ;4 byte pointer to parameter block sta >_toolErr rtl @unload dc.w $0005 CPC_Kill_did dc.w $0000 dc.w $801B dc.l @cdb dc.l $00000000 dc.l $00000000 @cdb dc.w $0000 dc.b $1B dcb.b 11,$00 dc.l $00000000 ENDP ;*********************************** ; CPC_Scan(data_pointer, requestCount, Width, Length) ; ; description: This call Reads the scanner Data ; entry: A pointer to the data destination, and a long count. ; exit: Carry set, and error code in Acc. ; ; NOTE: Here we must utilize the pointer we are ; handed...., and it must reflect the real ; data size ; ;*********************************** CPC_Scan PROC EXPORT IMPORT CPC_Type IMPORT CPC_Page_Ctrl IMPORT CPC_Hand_Ctrl IMPORT CPC_TRate IMPORT CPC_Scan_Len IMPORT CPC_Data IMPORT CPC_ReadRqst lda 6,S ;get the pointer to the window definition sta >CPC_buffer1+2 lda 4,S sta >CPC_buffer1 lda 10,S ;get the data length sta >t_rqst+2 sta >t_remain+2 lda 8,S sta >t_rqst sta >t_remain lda 12,S ;get the Scan Line Width sta >tw_width clc adc #$0003 lsr a lsr a sta >w_width lda 16,S ;get the data length sta >w_length ; ; Get the Scanner Type ; jsl CPCScan_GetMode bcs @exit1 ; ; Get the Scanner Resolution ; jsl CPC_XSense ; bcs @exit1 ; ; Which Scanner is it? ; lda >CPC_Type bmi @page ; ; It's a hand Scanner. ; Turn it on ; lda #$0101 sta >CPC_Page_Ctrl lda #$0001 sta >CPC_Type ; ; What DPI are we at? ; lda >CPC_TRate cmp #$0055 bge @dpi_400 cmp #$003F bge @dpi_300 blt @dpi_200 ; ; It's a Page Scanner. ; Turn it on ; @page lda #$0101 sta >CPC_Page_Ctrl lda #$0081 sta >CPC_Type ; ; What DPI are we at? ; lda >CPC_TRate cmp #$0071 bge @dpi_300 blt @dpi_200 ; ; Set the DPI Value. ; @dpi_400 lda #400 bra @set_dpi @dpi_300 lda #300 bra @set_dpi @dpi_200 lda #200 @set_dpi sta >CPC_Dpi ; ; Set the Scanner Type and turn the ; Scanner on ; lda #$0000 sta >CPC_MSdata jsl CPCScan_SetMode bcs @exit1 ; ; Set the Scan Line Width. ; lda >w_width xba sta >CPC_Scan_Len ; ; Set the Scanner Type and turn the ; Scanner on ; jsl CPCScan_SetMode bcc @GDS_Loop @exit1 brl @exit ; ; Does the Scanner have a Scan Line Yet? ; @GDS_Loop jsl CPC_GDStatus bcs @exit1 lda >CPC_Data xba cmp >w_width blt @GDS_Loop ; ; Get the Scan Line ; lda >w_width sta >CPC_ReadRqst jsl CPC_Read bcs @exit1 jsl covert2gray2 bcs @skip_buff ; ; Update the Buffer Pointer ; lda >CPC_buffer1 adc >tw_width sta >CPC_buffer1 lda >CPC_buffer1+2 adc #$0000 sta >CPC_buffer1+2 ; ; Update the Resulting Count ; @skip_buff lda >t_rslt adc >tw_width sta >t_rslt lda >t_rslt+2 adc #$0000 sta >t_rslt+2 ; ; Is there any more data requested> ; sec lda >t_remain sbc >tw_width sta >t_remain lda >t_remain+2 sbc #$0000 sta >t_remain+2 ora >t_remain beq @done ;No! Done with the Scan sec lda >t_remain sbc >tw_width ;Room for at least 1 more? lda >t_remain+2 sbc #$0000 blt @done ;No! Done with the Scan brl @GDS_Loop ;Yes. Go Get it ; ; No more data left. Stop the Scan ; @done jsl CPC_Unload bcs @exit sta >_toolErr lda >t_rslt+2 tax lda >t_rslt rtl @exit sta >_toolErr rtl w_width dc.l $0000 tw_width dc.l $0000 w_length dc.l $0000 CPC_Dpi dc.w $0000 t_rqst dc.l $00000000 t_remain dc.l $00000000 t_rslt dc.l $00000000 ; ; Scanned Data is 1 bit/pixel. We need to ; convert it to 4 bits/pixel. We will do this ; with a lookup table in 8 bit mode. ; covert2gray phb phk plb pei <$40 pei <$42 phy lda >CPC_buffer1 sta <$40 lda >CPC_buffer1+2 sta <$42 ldx w_width dex and #$00ff stx @src_ndx lda w_width asl a asl a dec a sta @dest_ndx lda #$0000 SHORTM @cvrt_loop ldy @src_ndx lda [$40],y tax lda HTone_2Gray3,x pha lda HTone_2Gray2,x pha lda HTone_2Gray1,x pha lda HTone_2Gray0,x ldy @dest_ndx sta [$40],y pla dey sta [$40],y pla dey sta [$40],y pla dey sta [$40],y dey sty @dest_ndx dec @src_ndx bpl @cvrt_loop LONGM ply pla sta <$42 pla sta <$40 plb @exit clc rtl @src_ndx dc.w $0000 @dest_ndx dc.w $0000 HTone_2Gray0 dc.b $00,$0f,$f0,$ff,$00,$0f,$f0,$ff,$00,$0f,$f0,$ff,$00,$0f,$f0,$ff dc.b $00,$0f,$f0,$ff,$00,$0f,$f0,$ff,$00,$0f,$f0,$ff,$00,$0f,$f0,$ff dc.b $00,$0f,$f0,$ff,$00,$0f,$f0,$ff,$00,$0f,$f0,$ff,$00,$0f,$f0,$ff dc.b $00,$0f,$f0,$ff,$00,$0f,$f0,$ff,$00,$0f,$f0,$ff,$00,$0f,$f0,$ff dc.b $00,$0f,$f0,$ff,$00,$0f,$f0,$ff,$00,$0f,$f0,$ff,$00,$0f,$f0,$ff dc.b $00,$0f,$f0,$ff,$00,$0f,$f0,$ff,$00,$0f,$f0,$ff,$00,$0f,$f0,$ff dc.b $00,$0f,$f0,$ff,$00,$0f,$f0,$ff,$00,$0f,$f0,$ff,$00,$0f,$f0,$ff dc.b $00,$0f,$f0,$ff,$00,$0f,$f0,$ff,$00,$0f,$f0,$ff,$00,$0f,$f0,$ff dc.b $00,$0f,$f0,$ff,$00,$0f,$f0,$ff,$00,$0f,$f0,$ff,$00,$0f,$f0,$ff dc.b $00,$0f,$f0,$ff,$00,$0f,$f0,$ff,$00,$0f,$f0,$ff,$00,$0f,$f0,$ff dc.b $00,$0f,$f0,$ff,$00,$0f,$f0,$ff,$00,$0f,$f0,$ff,$00,$0f,$f0,$ff dc.b $00,$0f,$f0,$ff,$00,$0f,$f0,$ff,$00,$0f,$f0,$ff,$00,$0f,$f0,$ff dc.b $00,$0f,$f0,$ff,$00,$0f,$f0,$ff,$00,$0f,$f0,$ff,$00,$0f,$f0,$ff dc.b $00,$0f,$f0,$ff,$00,$0f,$f0,$ff,$00,$0f,$f0,$ff,$00,$0f,$f0,$ff dc.b $00,$0f,$f0,$ff,$00,$0f,$f0,$ff,$00,$0f,$f0,$ff,$00,$0f,$f0,$ff dc.b $00,$0f,$f0,$ff,$00,$0f,$f0,$ff,$00,$0f,$f0,$ff,$00,$0f,$f0,$ff HTone_2Gray1 dc.b $00,$00,$00,$00,$0f,$0f,$0f,$0f,$f0,$f0,$f0,$f0,$ff,$ff,$ff,$ff dc.b $00,$00,$00,$00,$0f,$0f,$0f,$0f,$f0,$f0,$f0,$f0,$ff,$ff,$ff,$ff dc.b $00,$00,$00,$00,$0f,$0f,$0f,$0f,$f0,$f0,$f0,$f0,$ff,$ff,$ff,$ff dc.b $00,$00,$00,$00,$0f,$0f,$0f,$0f,$f0,$f0,$f0,$f0,$ff,$ff,$ff,$ff dc.b $00,$00,$00,$00,$0f,$0f,$0f,$0f,$f0,$f0,$f0,$f0,$ff,$ff,$ff,$ff dc.b $00,$00,$00,$00,$0f,$0f,$0f,$0f,$f0,$f0,$f0,$f0,$ff,$ff,$ff,$ff dc.b $00,$00,$00,$00,$0f,$0f,$0f,$0f,$f0,$f0,$f0,$f0,$ff,$ff,$ff,$ff dc.b $00,$00,$00,$00,$0f,$0f,$0f,$0f,$f0,$f0,$f0,$f0,$ff,$ff,$ff,$ff dc.b $00,$00,$00,$00,$0f,$0f,$0f,$0f,$f0,$f0,$f0,$f0,$ff,$ff,$ff,$ff dc.b $00,$00,$00,$00,$0f,$0f,$0f,$0f,$f0,$f0,$f0,$f0,$ff,$ff,$ff,$ff dc.b $00,$00,$00,$00,$0f,$0f,$0f,$0f,$f0,$f0,$f0,$f0,$ff,$ff,$ff,$ff dc.b $00,$00,$00,$00,$0f,$0f,$0f,$0f,$f0,$f0,$f0,$f0,$ff,$ff,$ff,$ff dc.b $00,$00,$00,$00,$0f,$0f,$0f,$0f,$f0,$f0,$f0,$f0,$ff,$ff,$ff,$ff dc.b $00,$00,$00,$00,$0f,$0f,$0f,$0f,$f0,$f0,$f0,$f0,$ff,$ff,$ff,$ff dc.b $00,$00,$00,$00,$0f,$0f,$0f,$0f,$f0,$f0,$f0,$f0,$ff,$ff,$ff,$ff dc.b $00,$00,$00,$00,$0f,$0f,$0f,$0f,$f0,$f0,$f0,$f0,$ff,$ff,$ff,$ff HTone_2Gray2 dc.b $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 dc.b $0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f dc.b $f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0 dc.b $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff dc.b $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 dc.b $0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f dc.b $f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0 dc.b $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff dc.b $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 dc.b $0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f dc.b $f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0 dc.b $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff dc.b $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 dc.b $0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f dc.b $f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0 dc.b $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff HTone_2Gray3 dc.b $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 dc.b $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 dc.b $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 dc.b $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 dc.b $0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f dc.b $0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f dc.b $0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f dc.b $0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f dc.b $f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0 dc.b $f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0 dc.b $f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0 dc.b $f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0 dc.b $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff dc.b $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff dc.b $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff dc.b $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff ; ; Scanned Data is 1 bit/pixel. We need to ; convert it to 4 bits/pixel. We will do this ; with a lookup table in 8 bit mode. ; covert2gray2 sec inc @pass beq @exit phb phk plb pei <$40 pei <$42 phy lda >CPC_buffer1 sta <$40 lda >CPC_buffer1+2 sta <$42 ldx w_width dex and #$00ff stx @src_ndx lda w_width asl a dec a sta @dest_ndx lda #$0000 SHORTM @cvrt_loop ldy @src_ndx lda [$40],y tax lda HTone_2Gray5,x pha lda HTone_2Gray4,x ldy @dest_ndx sta [$40],y pla dey sta [$40],y dey sty @dest_ndx dec @src_ndx bpl @cvrt_loop LONGM ply pla sta <$42 pla sta <$40 plb lda #$ffff sta @pass clc @exit rtl @src_ndx dc.w $0000 @dest_ndx dc.w $0000 @pass dc.w $ffff HTone_2Gray4 dc.b $00,$04,$03,$0C,$30,$78,$77,$CF,$40,$88,$87,$CF,$C4,$D5,$F7,$FF dc.b $00,$04,$03,$0C,$30,$78,$77,$CF,$40,$88,$87,$CF,$C4,$D5,$F7,$FF dc.b $00,$04,$03,$0C,$30,$78,$77,$CF,$40,$88,$87,$CF,$C4,$D5,$F7,$FF dc.b $00,$04,$03,$0C,$30,$78,$77,$CF,$40,$88,$87,$CF,$C4,$D5,$F7,$FF dc.b $00,$04,$03,$0C,$30,$78,$77,$CF,$40,$88,$87,$CF,$C4,$D5,$F7,$FF dc.b $00,$04,$03,$0C,$30,$78,$77,$CF,$40,$88,$87,$CF,$C4,$D5,$F7,$FF dc.b $00,$04,$03,$0C,$30,$78,$77,$CF,$40,$88,$87,$CF,$C4,$D5,$F7,$FF dc.b $00,$04,$03,$0C,$30,$78,$77,$CF,$40,$88,$87,$CF,$C4,$D5,$F7,$FF dc.b $00,$04,$03,$0C,$30,$78,$77,$CF,$40,$88,$87,$CF,$C4,$D5,$F7,$FF dc.b $00,$04,$03,$0C,$30,$78,$77,$CF,$40,$88,$87,$CF,$C4,$D5,$F7,$FF dc.b $00,$04,$03,$0C,$30,$78,$77,$CF,$40,$88,$87,$CF,$C4,$D5,$F7,$FF dc.b $00,$04,$03,$0C,$30,$78,$77,$CF,$40,$88,$87,$CF,$C4,$D5,$F7,$FF dc.b $00,$04,$03,$0C,$30,$78,$77,$CF,$40,$88,$87,$CF,$C4,$D5,$F7,$FF dc.b $00,$04,$03,$0C,$30,$78,$77,$CF,$40,$88,$87,$CF,$C4,$D5,$F7,$FF dc.b $00,$04,$03,$0C,$30,$78,$77,$CF,$40,$88,$87,$CF,$C4,$D5,$F7,$FF dc.b $00,$04,$03,$0C,$30,$78,$77,$CF,$40,$88,$87,$CF,$C4,$D5,$F7,$FF HTone_2Gray5 dcb.b 16,$00 dcb.b 16,$04 dcb.b 16,$03 dcb.b 16,$0C dcb.b 16,$30 dcb.b 16,$78 dcb.b 16,$77 dcb.b 16,$CF dcb.b 16,$40 dcb.b 16,$88 dcb.b 16,$87 dcb.b 16,$CF dcb.b 16,$C4 dcb.b 16,$D5 dcb.b 16,$F7 dcb.b 16,$FF ENDP ;*********************************** ; Scan_Inquiry() ; description: This call determines the Scanner Brand ; entry: None. ; exit: Carry set, and error code in Acc. ;*********************************** Scan_Inquiry PROC EXPORT ENTRY Inq_did ENTRY Inq_data jsl $e100a8 ;normal GS/OS entry point dc.w dstatus_call dc.l @Inquiry ;4 byte pointer to parameter block sta >_toolErr rtl @Inquiry dc.w $0005 Inq_did dc.w $0000 dc.w $8012 dc.l @cdb dc.l $00000020 dc.l $00000000 @cdb dc.w $0000 dc.b $12 dcb.b 3,$00 dc.b $20 dcb.b 7,$00 dc.l Inq_data Inq_data dcb.b $20,$00 ENDP ;*********************************** ; ; Scanner_Open(); ; description: Find and open the scanner device ; entry: None. ; exit: carry set, and error code in Acc if an error occurs. ; ;*********************************** Scanner_Open PROC EXPORT IMPORT c_dref,Scanner_Type lda >scanDevnum ;copy scanner device ID to various parm blocks sta >scanner_did sta >ms_did sta >send_did sta >dfw_did sta >scan_did sta >wait_did sta >CPCms_did sta >CPCmsen_did sta >CPC_GDS_did sta >CPC_XS_did sta >CPCRead_did sta >CPC_Kill_did sta >Inq_did ; ; Do the Scanner Inquiry Call. This way we can ID the Type of Scanner that ; we are dealing with. ; jsl Scan_Inquiry bcs @exit ; ; What Scanner do We have? ; ldx #$0010 @Apple_Loop lda >Inq_data,x cmp >Apple_String,x bne @chk_CPC dex bpl @Apple_Loop jmp Apple_Open @chk_CPC ldx #$0010 @CPC_Loop lda >Inq_data,x cmp >CPC_String,x bne @chk_NuScan dex bpl @CPC_Loop jmp CPC_Open @chk_NuScan ldx #$0010 @NuScan_Loop lda >Inq_data,x cmp >NuScan_String,x bne @None dex bpl @NuScan_Loop jmp NuScan_Open @None lda #$002f sec @exit sta >_toolErr rtl STRING ASIS Apple_String dc.b $06,$00,$02,$02,$2C,$00,$00,$00 dc.b 'APPLE SCANNER A9M0337 ' CPC_String dc.b $06,$00,$02,$02,$28,$00,$00,$00 dc.b 'CPC INC Smart Scan(FW) ' NuScan_String dc.b $06,$00,$02,$02,$28,$00,$00,$00 dc.b 'CPC INC Smart Scan(FW) ' ; ; Start point for finalizing the Apple Scanner Open Call ; make a DInfo call to get the device name ; Apple_Open jsl $e100a8 ;normal GS/OS entry point dc.w dinfo_call dc.l get_scan_name ;4 byte pointer to parameter block bcs @exit ; ; Now that we have the name, we can open the device (using the Character FST) ; jsl $e100a8 ;normal GS/OS entry point dc.w open_call dc.l dvc_open ;4 byte pointer to parameter block bcs @exit ;say goodnight if errors lda >open_dref ;copy reference number to other parm blocks sta >r_dref sta >c_dref ; ; Now that it's open, we can set wait mode to WAIT ; jsl $e100a8 ;normal GS/OS entry point dc.w dcontrol_call dc.l wait ;4 byte pointer to parameter block bcs @exit lda #$0000 sta >Scanner_Type lda #$0000 @exit sta >_toolErr rtl get_scan_name dc.w $0002 ;pCount scanner_did dc.w $0000 dc.l scan_dname_buf export open_dref dvc_open dc.w $0002 open_dref dc.w $0000 dc.l scan_dname STRING asis scan_dname_buf dc.w 36 ;ResultBuf32 length is 36 bytes scan_dname ds.w 1 ;returned length word ds.b 32 ;space for returned device name STRING PASCAL wait dc.w $0005 wait_did dc.w $0000 dc.w $0004 dc.l @cdb dc.l $00000002 dc.l $00000000 @cdb dc.w $0000 ;set wait mode ; ; Start point for finalizing the CPC Scanner Open Call ; CPC_Open lda #$0001 sta >Scanner_Type lda #$0000 clc sta >_toolErr rtl ; ; Start point for finalizing the NuScan Scanner Open Call ; NuScan_Open lda #$0002 sta >Scanner_Type lda #$0000 clc sta >_toolErr rtl ENDP ;*********************************** ; Scanner_Close() ; description: This call closes the scanner device ; entry: None. ; exit: Carry set, and error code in Acc. ;*********************************** Scanner_Close PROC EXPORT ENTRY c_dref clc lda >c_dref beq @close jsl $e100a8 ;normal GS/OS entry point dc.w close_call dc.l close ;4 byte pointer to parameter block @close sta >_toolErr rtl close dc.w $0001 export c_dref c_dref dc.w $0000 ENDP END \ No newline at end of file diff --git a/scsi2/AppleScanGS/Scanner.GSOS.h b/scsi2/AppleScanGS/Scanner.GSOS.h new file mode 100644 index 0000000..89d61cc --- /dev/null +++ b/scsi2/AppleScanGS/Scanner.GSOS.h @@ -0,0 +1 @@ +extern void Scanner_Open(); extern Long Scanner_Read(); extern void Scanner_Close(); extern void Scanner_Scan(); extern void Scanner_DefWindow(); extern void Scanner_SetHalfTones(); extern void Scanner_SetMode(); extern void CPCScan_SetMode(); extern void CPCScan_GetMode(); extern void CPC_GDStatus(); extern void CPC_XSense(); extern void CPC_Read(); extern void CPC_Unload(); extern Long CPC_Scan(); extern void Scan_Inquiry(); \ No newline at end of file diff --git a/scsi2/AppleScanGS/ScannerDefs.h b/scsi2/AppleScanGS/ScannerDefs.h new file mode 100644 index 0000000..ceec8a4 --- /dev/null +++ b/scsi2/AppleScanGS/ScannerDefs.h @@ -0,0 +1 @@ +#define fFamily0 0x1 #define fFamily1 0x2 #define fFamily2 0x3 /**********************************/ /* */ /* window resource ID definitions */ /* */ /**********************************/ #ifdef RezIIGS #define ImageWindow 0x00000001 #define ScannerWindow 0x00001100 #define PreviewWindow 0x00001200 #define PrefWindow 0x00001300 #define SettingsWindow 0x00001400 #define ThermWindow 0x00001500 #else #define ImageWindow 0x00000001L #define ScannerWindow 0x00001100L #define PreviewWindow 0x00001200L #define PrefWindow 0x00001300L #define SettingsWindow 0x00001400L #define ThermWindow 0x00001500L #endif #ifdef RezIIGS #define ScannerWindowID 0x00001101 #define PreviewWindowID 0x00001201 #define PrefWindowID 0x00001301 #else #define ScannerWindowID 0x00001101L #define PreviewWindowID 0x00001201L #define PrefWindowID 0x00001301L #endif #ifdef RezIIGS #define SettingsWindowID 0x00001401 #define CompositionPopUp 0x00001410 #define CompositionPopUpItem1 0x00001411 #define CompositionPopUpItem2 0x00001412 #define CompositionPopUpItem3 0x00001413 #define XResolutionPopUp 0x00001420 #define XResolutionPopUpItem1 0x00001421 #define XResolutionPopUpItem2 0x00001422 #define XResolutionPopUpItem3 0x00001423 #define XResolutionPopUpItem4 0x00001424 #define XResolutionPopUpItem5 0x00001425 #define YResolutionPopUp 0x00001430 #define YResolutionPopUpItem1 0x00001431 #define YResolutionPopUpItem2 0x00001432 #define YResolutionPopUpItem3 0x00001433 #define YResolutionPopUpItem4 0x00001434 #define YResolutionPopUpItem5 0x00001435 #define BrightnessScroll 0x00001440 #define BrightnessStatText 0x00001441 #define ContrastScroll 0x00001450 #define ContrastStatText 0x00001451 #define ThresholdScroll 0x00001460 #define ThresholdStatText 0x00001461 #define ScanButton 0x00001470 #define PreviewButton 0x00001480 #else #define SettingsWindowID 0x00001401L #define CompositionPopUp 0x00001410L #define CompositionPopUpItem1 0x00001411L #define CompositionPopUpItem2 0x00001412L #define CompositionPopUpItem3 0x00001413L #define XResolutionPopUp 0x00001420L #define XResolutionPopUpItem1 0x00001421L #define XResolutionPopUpItem2 0x00001422L #define XResolutionPopUpItem3 0x00001423L #define XResolutionPopUpItem4 0x00001424L #define XResolutionPopUpItem5 0x00001425L #define YResolutionPopUp 0x00001430L #define YResolutionPopUpItem1 0x00001431L #define YResolutionPopUpItem2 0x00001432L #define YResolutionPopUpItem3 0x00001433L #define YResolutionPopUpItem4 0x00001434L #define YResolutionPopUpItem5 0x00001435L #define BrightnessScroll 0x00001440L #define BrightnessStatText 0x00001441L #define ContrastScroll 0x00001450L #define ContrastStatText 0x00001451L #define ThresholdScroll 0x00001460L #define ThresholdStatText 0x00001461L #define ScanButton 0x00001470L #define PreviewButton 0x00001480L #endif #ifdef RezIIGS #define PalletteWindowID 0x00001501 #define ToolWindowID 0x00001601 #else #define PalletteWindowID 0x00001501L #define ToolWindowID 0x00001601L #endif /********************************/ /* */ /* Menu resource ID definitions */ /* */ /********************************/ #define AppleMenuID 0x901 #define FileMenuID 0x902 #define EditMenuID 0x903 #define ScanMenuID 0x904 #define UndoID 250 /* For DA's */ #define CutID 251 /* For DA's */ #define CopyID 252 /* For DA's */ #define PasteID 253 /* For DA's */ #define ClearID 254 /* For DA's */ #define CloseID 255 /* For DA's */ #define AboutID CloseID+1 #define OpenID AboutID+1 #define SaveID OpenID+1 #define SaveAsID SaveID+1 #define PrefID SaveAsID+1 #define PrintID PrefID+1 #define QuitID PrintID+1 #define SettingsID QuitID+1 #define PreviewID SettingsID+1 /********************************/ /* */ /* Alert String resource IDs */ /* */ /********************************/ #define AboutBox 1 #define noMemAvailable 2 #define noScannerFound 3 #define scannerNotReady 4 \ No newline at end of file diff --git a/scsi2/AppleScanGS/Utils.c b/scsi2/AppleScanGS/Utils.c new file mode 100644 index 0000000..11accb3 --- /dev/null +++ b/scsi2/AppleScanGS/Utils.c @@ -0,0 +1 @@ +#include #include #include #include #include #include #include #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; } \ No newline at end of file diff --git a/scsi2/AppleScanGS/Window.c b/scsi2/AppleScanGS/Window.c new file mode 100644 index 0000000..02b3677 --- /dev/null +++ b/scsi2/AppleScanGS/Window.c @@ -0,0 +1 @@ +/*********************************************************************** * * Window.c * * Copyright (c) 1990 * Apple Computer, Inc. * All Rights Reserved. * * This file contains the code which implements * windows in the scanner program. * ***********************************************************************/ #include #include #include #include #include #include #include #include #include #include #include #include "Scan.h" #define xRulerInset 10 #define yRulerInset 10 extern scannerWindowDef sWindowDef; extern unsigned int staggerCount; extern PicHndl previewRuler; void updatePreviewWindow(); extern GrafPortPtr previewWindowPtr; extern GrafPortPtr settingsWindowPtr; /* grayscale pallette */ int cTable[16]= {0x000,0x111,0x222,0x333,0x444,0x555,0x666,0x777, 0x888,0x999,0xAAA,0xBBB,0xCCC,0xDDD,0xEEE,0xFFF}; /* standard pallette */ int defCTable[16] = {0x000,0x777,0x841,0x72C,0x00F,0x080,0xF70,0xD00, 0xFA9,0xFF0,0x0E0,0x4DF,0xDAF,0x78F,0xCCC,0xFFF}; /*************************************************************************************************/ static CtlRecHndl makeBoxCtl(theWindow) GrafPortPtr theWindow; { CtlRecHndl boxCtl; static Rect boxRect = { YINSET,XINSET,YINSET+(11*vPPI)+1,XINSET+((85*hPPI)/10)+1 }; static int boxData[] = { YINSET, /* min Y */ XINSET, /* min X */ YINSET+(14*vPPI)+1, /* max Y */ XINSET+((85*hPPI)/10)+1,/* max X */ 10, /* minimum height */ 16, /* minimum width */ 1, /* grid Y */ 1 }; /* grid X */ static int boxColorTbl = 0x00B0; extern void BoxProc(); boxCtl = NewControl(theWindow,&boxRect,NULL,0x0006,0x0303,boxData,BoxProc,NULL,&boxColorTbl); /* | | | | | | | | ColorTable | | | | | | | RefCon | | | | | | DefProc | | | | | custom data | | | | width/heighth of knobs | | | ctlFlag | | title pointer | control rectangle window pointer */ if(_toolErr) ErrorWindow(0,NULL,_toolErr); return(boxCtl); } openPreview() { #define bufferSize 968L Handle tempHandle, bufferHandle; LocInfoPtr theLocInfo; GrafPortPtr theWindow; Rect *theRect; int fontWidth, rulerDepth1,rulerDepth2; unsigned i; if(previewWindowPtr != NULL) { SelectWindow(previewWindowPtr); } else { bufferHandle = NewHandle(bufferSize,_ownerid,attrFixed,NULL); if(_toolErr != 0) { AlertWindow(4,NULL,(long) noMemAvailable); } else { tempHandle = NewHandle((long)sizeof(LocInfo),_ownerid,attrFixed,NULL); theLocInfo = (LocInfoPtr)*tempHandle; theLocInfo->portSCB = (sWindowDef.bitsPerPixel == 4) ? 0x80 : 0; theLocInfo->ptrToPixImage = *bufferHandle; theLocInfo->width = (104 * sWindowDef.bitsPerPixel + 7)/8; theLocInfo->boundsRect.v1 = 0; theLocInfo->boundsRect.h1 = 0; theLocInfo->boundsRect.v2 = 149; theLocInfo->boundsRect.h2 = 104; theWindow = NewWindow2(NULL,theLocInfo,updatePreviewWindow,NULL,2,PreviewWindow,rWindParam1); SetPort(theWindow); previewWindowPtr = theWindow; SetDataSize(180,120,theWindow); makeBoxCtl(theWindow); /* go add the custom control */ if((previewRuler == NULL)) { fontWidth = 8; SetOrigin(0,0); GetPortRect(&theRect); rulerDepth1 = fontWidth+7; rulerDepth2 = (2*fontWidth)+7; previewRuler = OpenPicture(&theRect); MoveTo(XINSET-XOFFSET,YINSET); /* draw the vertical ruler first */ /* draw hash marks */ for(i = 0; i < 14; ++i) { Move(0,vPPI>>1); /* move to first hash mark */ Line(-3,0); /* draw half-inch mark */ Move(-4,vPPI>>1); /* move to full hash mark */ Line(7,0); /* draw full-inch mark */ } Move(0,-((vPPI*14)-4)); /* move back to top of ruler + 4 to center numerals */ /* mark the ruler divisions */ for(i = 2; i < 10; i += 2) { Move(-rulerDepth1,vPPI<<1); DrawChar('0'+i); Move(7,0); } for(i = 10; i < 14; i += 2) { Move(-rulerDepth2,vPPI<<1); DrawChar('1'); DrawChar('0'+(i-10)); Move(7,0); } Move(0,(vPPI*2)-4); /* position pen to bottom right corner */ /* then draw the ruler rectangle */ Line(-27,0); /* bottom */ Line(0,-(vPPI*14)); /* left side */ Line(27,0); /* top */ Line(0,(vPPI*14)); /* right side of ruler box */ /* now draw the ruler along the top */ Move(XOFFSET,-(vPPI*14+YOFFSET)); /* vertical ruler stopped at bottom right corner */ /* draw the hash marks */ for(i = 0; i < 8; ++i) { Move(hPPI>>1,0); Line(0,-2); Move(hPPI>>1,-2); Line(0,4); } Move(hPPI>>1,0); /* the 8 1/2 mark */ Line(0,-2); Move(-((hPPI*8)+(hPPI>>1)-(fontWidth>>1)),2); /* reposition back to start of ruler */ /* draw the ruler divisions */ for(i = 2; i < 10; i += 2) { Move((hPPI<<1)-fontWidth,-5); DrawChar('0'+i); Move(0,5); } Move((hPPI>>1)-(fontWidth>>1),0); /* move to lower-right corner of ruler */ /* draw the ruler frame */ Line(0,-14); Line(-((hPPI*8)+(hPPI>>1)),0); Line(0,14); Line(((hPPI*8)+(hPPI>>1)),0); ClosePicture(); } EnableMItem(CloseID); } } } #if 0 /* is this used? */ /***********************************************************************/ void drawMousePos(){ MouseRec thisMouseRec; CtlRecHndl ctlHandle; GrafPortPtr thisPort; Pointer theXArrayList[1]; Pointer theYArrayList[1]; static char xString[] = {"0000"}; static char yString[] = {"0000"}; theXArrayList[0] = xString; theYArrayList[0] = yString; if(settingsWindowPtr != 0){ thisMouseRec = ReadMouse(); /* thisPort = GetPort(); SetPort(settingsWindowPtr); */ /* ctlHandle = GetCtlHandleFromID(settingsWindowPtr,WinXEndText); Int2Dec(thisMouseRec.xPos,xString,4,FALSE); SetCtlParamPtr(theXArrayList); DrawOneCtl(ctlHandle); ctlHandle = GetCtlHandleFromID(settingsWindowPtr,WinYEndText); Int2Dec(thisMouseRec.yPos,yString,4,FALSE); SetCtlParamPtr(theYArrayList); DrawOneCtl(ctlHandle); */ /* SetPort(thisPort); */ } } /*********************************************************************** * * doInPreview * * This routine draws the contents of all the windows. * ***********************************************************************/ void doInPreview(mouseStart) Point mouseStart; { CtlRecHndl ctlHandle; Pointer theXArrayList[1]; Pointer theYArrayList[1]; static char xString[] = {"0000"}; static char yString[] = {"0000"}; Rect limitRect,slopRect; Point mouseEnd; word dragFlag, penMode; Long changePos; static char test[32]={0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff}; static char penMaskUnDraw[32]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; theXArrayList[0] = xString; theYArrayList[0] = yString; penMode = GetPenMode(); /* SetPenMode(modeXOR); SetPenMask( */ if(((dragRect.v1)|(dragRect.h1)|(dragRect.v2)|(dragRect.h2))) { FrameRect(&dragRect); } GetPortRect(&slopRect); limitRect.v1 = slopRect.v1 + YINSET-1; limitRect.h1 = slopRect.h1 + XINSET-4; limitRect.v2 = slopRect.v2 -5; limitRect.h2 = slopRect.h2 -109; GlobalToLocal(&mouseStart); if(mouseStart.h < limitRect.h1) mouseStart.h = limitRect.h1; if(mouseStart.v < limitRect.v1) mouseStart.v = limitRect.v1; if(mouseStart.h > limitRect.h2) mouseStart.h = limitRect.h2; if(mouseStart.v > limitRect.v2) mouseStart.v = limitRect.v2; /* ctlHandle = GetCtlHandleFromID(settingsWindowPtr,WinYStartText); Int2Dec(mouseStart.v,yString,4,FALSE); SetCtlParamPtr(theYArrayList); DrawOneCtl(ctlHandle); ctlHandle = GetCtlHandleFromID(settingsWindowPtr,WinXStartText); Int2Dec(mouseStart.h,xString,4,FALSE); SetCtlParamPtr(theXArrayList); DrawOneCtl(ctlHandle); */ SetRect(&dragRect,mouseStart,mouseStart.h+2,mouseStart.v+2); dragFlag = 0x0424; /* minimum of 4 pixels, return the final rect, drag rubberband rectangle */ DragRect(drawMousePos,test,mouseStart.h,mouseStart.v,&dragRect,&limitRect,&slopRect,dragFlag); FrameRect(&dragRect); SetPenMode(penMode); } #endif /*********************************************************************** * * drawThisWindow * * This routine draws the contents of all the windows. * ***********************************************************************/ void drawThisWindow() { DrawControls(GetPort()); } /*********************************************************************** * * doCloseTop * * This routine closes the topmost window. We do a little work to * prevent the main window from being closed. * ***********************************************************************/ void doCloseTop() { GrafPortPtr tempWin; LocInfoPtr theLocInfo; char **nameHndl; unsigned int k; tempWin = FrontWindow(); if(tempWin == previewWindowPtr) { previewWindowPtr = NULL; } if(tempWin == settingsWindowPtr) { settingsWindowPtr = NULL; } if(tempWin != NULL) { if (theLocInfo = (LocInfoPtr)GetWRefCon(tempWin)) { DisposeHandle(FindHandle(theLocInfo->ptrToPixImage)); DisposeHandle(FindHandle(theLocInfo)); } nameHndl = (char **) GetWTitle(tempWin); /* was the name allocated by us? */ if(!((long) nameHndl & 0x80000000)) /* not if it's a handle */ free(nameHndl); /* else dipose of it */ CloseWindow(tempWin); } if(!FrontWindow()) DisableMItem(CloseID); } /*********************************************************************** * * openThisWindow * * This routine either opens the specified window or brings it to the top * if it is already open. * * If it is not open, we open it with NewWindow2 invisibly, adjust the window's * location and then show and select the window. * ***********************************************************************/ GrafPortPtr openThisWindow(ctlid) unsigned long ctlid; { GrafPortPtr wptr; wptr = NewWindow2(NULL, NULL, drawThisWindow, NULL, 2, ctlid, rWindParam1); if (ctlid < AppWindow) { MoveWindow (50 + 8 * staggerCount, 50 + 8 * staggerCount, wptr); staggerCount++; staggerCount &= 0x0F; } SelectWindow(wptr); return(wptr); } /*********************************************************************** * * setupWindows - initializes window stuff prior to entering event loop * ***********************************************************************/ void setupWindows() { extern void doSettingsItem(); doSettingsItem(); return; } /*********************************************************************** * * updateScannerWindow() * * updates the bit mapped windows with the scanned data. * ***********************************************************************/ void updateScannerWindow() { LocInfoPtr theSrcLoc = (LocInfoPtr)GetWRefCon(GetPort()); PPToPort(theSrcLoc,&theSrcLoc->boundsRect,0,0,notCopy); if (_toolErr) ErrorWindow(0,NULL, _toolErr); } /*********************************************************************** * * updatePreviewWindow() * * updates the bit mapped windows with the scanned data. * ***********************************************************************/ void updatePreviewWindow() { Rect theRect, pageRect; LocInfoPtr theSrcLoc = (LocInfoPtr)GetWRefCon(GetPort()); GetPortRect(&theRect); DrawPicture(previewRuler,&theRect); /* if((dragRect.h1|dragRect.h2|dragRect.v1|dragRect.v2) != 0) { FrameRect(&dragRect); } */ pageRect.v1 = YINSET-1; pageRect.v2 = YINSET + (14 * vPPI) + 2; pageRect.h1 = XINSET-1; pageRect.h2 = XINSET + (8 * hPPI) + (hPPI >> 1) + 2; SetSolidPenPat(7); FrameRect(&pageRect); if (_toolErr) ErrorWindow(0,NULL,_toolErr); SetSolidPenPat(0); DrawControls(previewWindowPtr); } /*********************************************************************** * * doOpenImage * * ***********************************************************************/ void doOpenImage(dataWidth, dataLength, bufferHandle) unsigned long dataWidth, dataLength; Handle bufferHandle; { char *windowName; LocInfoPtr theLocInfo; GrafPortPtr theWindow; Handle tempHandle; int mode; int pixelWidth; static char windNum = '1'; /* Check the screen mode and multiply by 2 if 640 */ mode = (GetMasterSCB() & 0x0080) ? 1 : 2; pixelWidth = (dataWidth * 8) >> mode; tempHandle = NewHandle((long)sizeof(LocInfo),_ownerid,attrFixed,NULL); theLocInfo = (LocInfoPtr)*tempHandle; theLocInfo->portSCB = (mode == 2) ? 0x00 : 0x80; theLocInfo->ptrToPixImage = *bufferHandle; theLocInfo->width = dataWidth; theLocInfo->boundsRect.v1 = 0; theLocInfo->boundsRect.h1 = 0; theLocInfo->boundsRect.v2 = dataLength; theLocInfo->boundsRect.h2 = pixelWidth; windowName = malloc(12); /* get memory for window title */ memcpy(windowName,"\p Untitled ",12); windowName[10] = windNum; if(++windNum > '9') /* adjust window number for next time through */ windNum = '1'; theWindow = NewWindow2(windowName,theLocInfo,updateScannerWindow,NULL,2,ImageWindow,rWindParam1); SetPort(theWindow); SetDataSize(pixelWidth,(short)dataLength,theWindow); EnableMItem(CloseID); free(windowName); } \ No newline at end of file diff --git a/scsi2/AppleScanGS/doScan..aii b/scsi2/AppleScanGS/doScan..aii new file mode 100644 index 0000000..dc30691 --- /dev/null +++ b/scsi2/AppleScanGS/doScan..aii @@ -0,0 +1 @@ +/*********************************************************************************************/ 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); } \ No newline at end of file diff --git a/scsi2/AppleScanGS/xSaveFile.c b/scsi2/AppleScanGS/xSaveFile.c new file mode 100644 index 0000000..71f0e13 --- /dev/null +++ b/scsi2/AppleScanGS/xSaveFile.c @@ -0,0 +1 @@ +#include #include #include #include #include #include #include typedef struct { long blkSize; char identLen; char ident[4]; int mscb; int pixPerLine; int palletteCount; int pallette[16]; int scanLines; } infoBlockHdr; typedef struct { int numBytes; int modeWord; } dirEntry; infoBlockHdr picHeader = { 0, /* size of data block (get's filled in) */ 4, {'M', 'A', 'I', 'N'}, 0, /* master control word */ 320, /* pixels per scan line */ 1, /* number of pallettes */ {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, /* pallette */ 200 /* # of scan lines */ }; CreateRecGS createblk; NameRecGS destroyblk; OpenRecGS openblk; IORecGS readblk; IORecGS writeblk; RefNumRecGS closeblk; SetPositionRecGS setpositionblk; typedef struct { word slices; word width; char image[8 * 11]; char mask[8 * 11]; Point hotSpot; } myCursor; #define hotY 0 #define hotX 2 static myCursor cursor0 = { 11, 4, /* 0 */ { 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x0f,0x00,0x00,0x0f,0x00,0x00,0x00, 0x00,0xf0,0x00,0xf0,0x00,0xf0,0x00,0x00, 0x00,0xf0,0xff,0xf0,0x00,0xff,0x00,0x00, 0x00,0xf0,0x00,0x00,0x00,0xf0,0x00,0x00, 0x00,0x0f,0x00,0x00,0x0f,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00 }, { 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x0f,0xff,0xff,0xff,0x00,0x00,0x00, 0x00,0xff,0xff,0xff,0xff,0xf0,0x00,0x00, 0x00,0xff,0xff,0xff,0xff,0xff,0x00,0x00, 0x00,0xff,0xff,0xff,0xff,0xf0,0x00,0x00, 0x00,0x0f,0xff,0xff,0xff,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00 }, hotY, hotX }; static myCursor cursor1 = { 11, 4, /* 1 */ { 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x0f,0xf0,0x00,0x0f,0x00,0x00,0x00, 0x00,0xf0,0x0f,0xf0,0x00,0xf0,0x00,0x00, 0x00,0xf0,0x00,0xf0,0x00,0xff,0x00,0x00, 0x00,0xf0,0x00,0x00,0x00,0xf0,0x00,0x00, 0x00,0x0f,0x00,0x00,0x0f,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00 }, { 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x0f,0xff,0xff,0xff,0x00,0x00,0x00, 0x00,0xff,0xff,0xff,0xff,0xf0,0x00,0x00, 0x00,0xff,0xff,0xff,0xff,0xff,0x00,0x00, 0x00,0xff,0xff,0xff,0xff,0xf0,0x00,0x00, 0x00,0x0f,0xff,0xff,0xff,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00 }, hotY, hotX }; static myCursor cursor2 = { 11, 4, /* 2 */ { 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x0f,0x00,0xf0,0x0f,0x00,0x00,0x00, 0x00,0xf0,0x00,0xf0,0x00,0xf0,0x00,0x00, 0x00,0xf0,0x00,0xf0,0x00,0xff,0x00,0x00, 0x00,0xf0,0x00,0x00,0x00,0xf0,0x00,0x00, 0x00,0x0f,0x00,0x00,0x0f,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00 }, { 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x0f,0xff,0xff,0xff,0x00,0x00,0x00, 0x00,0xff,0xff,0xff,0xff,0xf0,0x00,0x00, 0x00,0xff,0xff,0xff,0xff,0xff,0x00,0x00, 0x00,0xff,0xff,0xff,0xff,0xf0,0x00,0x00, 0x00,0x0f,0xff,0xff,0xff,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00 }, hotY, hotX }; static myCursor cursor3 = { 11, 4, /* 3 */ { 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x0f,0x00,0x00,0xff,0x00,0x00,0x00, 0x00,0xf0,0x00,0xff,0x00,0xf0,0x00,0x00, 0x00,0xf0,0x00,0xf0,0x00,0xff,0x00,0x00, 0x00,0xf0,0x00,0x00,0x00,0xf0,0x00,0x00, 0x00,0x0f,0x00,0x00,0x0f,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00 }, { 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x0f,0xff,0xff,0xff,0x00,0x00,0x00, 0x00,0xff,0xff,0xff,0xff,0xf0,0x00,0x00, 0x00,0xff,0xff,0xff,0xff,0xff,0x00,0x00, 0x00,0xff,0xff,0xff,0xff,0xf0,0x00,0x00, 0x00,0x0f,0xff,0xff,0xff,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00 }, hotY, hotX }; static myCursor cursor4 = { 11, 4, /* 4 */ { 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x0f,0x00,0x00,0x0f,0x00,0x00,0x00, 0x00,0xf0,0x00,0xf0,0x00,0xf0,0x00,0x00, 0x00,0xf0,0x00,0xff,0xf0,0xff,0x00,0x00, 0x00,0xf0,0x00,0x00,0x00,0xf0,0x00,0x00, 0x00,0x0f,0x00,0x00,0x0f,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00 }, { 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x0f,0xff,0xff,0xff,0x00,0x00,0x00, 0x00,0xff,0xff,0xff,0xff,0xf0,0x00,0x00, 0x00,0xff,0xff,0xff,0xff,0xff,0x00,0x00, 0x00,0xff,0xff,0xff,0xff,0xf0,0x00,0x00, 0x00,0x0f,0xff,0xff,0xff,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00 }, hotY, hotX }; static myCursor cursor5 = { 11, 4, /* 5 */ { 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x0f,0x00,0x00,0x0f,0x00,0x00,0x00, 0x00,0xf0,0x00,0xf0,0x00,0xf0,0x00,0x00, 0x00,0xf0,0x00,0xf0,0x00,0xff,0x00,0x00, 0x00,0xf0,0x00,0x0f,0x00,0xf0,0x00,0x00, 0x00,0x0f,0x00,0x00,0xff,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00 }, { 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x0f,0xff,0xff,0xff,0x00,0x00,0x00, 0x00,0xff,0xff,0xff,0xff,0xf0,0x00,0x00, 0x00,0xff,0xff,0xff,0xff,0xff,0x00,0x00, 0x00,0xff,0xff,0xff,0xff,0xf0,0x00,0x00, 0x00,0x0f,0xff,0xff,0xff,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00 }, hotY, hotX }; static myCursor cursor6 = { 11, 4, /* 6 */ { 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x0f,0x00,0x00,0x0f,0x00,0x00,0x00, 0x00,0xf0,0x00,0xf0,0x00,0xf0,0x00,0x00, 0x00,0xf0,0x00,0xf0,0x00,0xff,0x00,0x00, 0x00,0xf0,0x00,0xf0,0x00,0xf0,0x00,0x00, 0x00,0x0f,0x00,0xf0,0x0f,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00 }, { 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x0f,0xff,0xff,0xff,0x00,0x00,0x00, 0x00,0xff,0xff,0xff,0xff,0xf0,0x00,0x00, 0x00,0xff,0xff,0xff,0xff,0xff,0x00,0x00, 0x00,0xff,0xff,0xff,0xff,0xf0,0x00,0x00, 0x00,0x0f,0xff,0xff,0xff,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00 }, hotY, hotX }; static myCursor cursor7 = { 11, 4, /* 7 */ { 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x0f,0x00,0x00,0x0f,0x00,0x00,0x00, 0x00,0xf0,0x00,0xf0,0x00,0xf0,0x00,0x00, 0x00,0xf0,0x00,0xf0,0x00,0xff,0x00,0x00, 0x00,0xf0,0x0f,0x00,0x00,0xf0,0x00,0x00, 0x00,0x0f,0xf0,0x00,0x0f,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00 }, { 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x0f,0xff,0xff,0xff,0x00,0x00,0x00, 0x00,0xff,0xff,0xff,0xff,0xf0,0x00,0x00, 0x00,0xff,0xff,0xff,0xff,0xff,0x00,0x00, 0x00,0xff,0xff,0xff,0xff,0xf0,0x00,0x00, 0x00,0x0f,0xff,0xff,0xff,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00, 0x00,0x00,0xff,0xff,0xf0,0x00,0x00,0x00 }, hotY, hotX }; static myCursor *animCursor[8] = {&cursor0,&cursor1,&cursor2,&cursor3,&cursor4,&cursor5,&cursor6,&cursor7}; int SavePic(pathname, RefPtr) GSString255 *pathname; LocInfoPtr RefPtr; { extern int cTable[16]; char *invertBuf, *dummyBuf; char *srcptr,*dstptr; dirEntry *ScanLineDirectory; /* dynamic array */ unsigned cursNum = 0; unsigned counter = 0; unsigned linenum, srcSize, dstSize; unsigned lineWidth, numLines; unsigned i; int errNum; word oldSCB; long totalSize; WaitCursor(); lineWidth = RefPtr->width; /* get # of bytes per scan line */ numLines = RefPtr->boundsRect.v2 - RefPtr->boundsRect.v1; /* # of scan lines */ /* get memory for scan line directory array */ if(!(ScanLineDirectory = (dirEntry *) malloc(numLines * sizeof(dirEntry)))) return(0x54); if(!(dstptr = malloc(lineWidth))) { /* allocate memory for converted scan line */ free(ScanLineDirectory); return(0x54); /* return error condition */ } if(!(invertBuf = malloc(lineWidth + 160))) { /* allocate memory for inverted scan line */ free(dstptr); free(ScanLineDirectory); return(0x54); /* return error condition */ } destroyblk.pCount = closeblk.pCount = 1; destroyblk.pathname = pathname; DestroyGS(&destroyblk); createblk.pCount = 4; createblk.pathname = pathname; createblk.access = 0xE3; createblk.fileType = 0xC0; createblk.auxType = 2; CreateGS(&createblk); if(errNum = /* assignment */ _toolErr) goto goodbye2; /* messy, but efficient! */ openblk.pCount = 3; openblk.pathname = pathname; openblk.requestAccess = 2; /* write only */ OpenGS(&openblk); if(errNum = /* assignment */ _toolErr) goto goodbye2; SetMasterSCB((oldSCB = GetMasterSCB()) | 0x0100); /* make sure cursor doesn't flicker */ setpositionblk.pCount = 3; setpositionblk.refNum = closeblk.refNum = openblk.refNum; setpositionblk.base = 0; setpositionblk.displacement = totalSize = sizeof(picHeader) + (numLines * sizeof(dirEntry)); /* adjust EOF and mark past header fields of file */ SetEOFGS(&setpositionblk); if(errNum = /* assignment */ _toolErr) goto goodbye; /* messy, but efficient! */ SetMarkGS(&setpositionblk); if(errNum = /* assignment */ _toolErr) goto goodbye; /* messy, but efficient! */ writeblk.pCount = 4; writeblk.refNum = openblk.refNum; srcptr = RefPtr->ptrToPixImage; /* initialize source pointer */ writeblk.dataBuffer = dstptr; for(linenum = 0; linenum < numLines; ++linenum) { asm { /* invert the bytes of the scan line */ ldy #0 ; get the # of bytes in the line ldx #0xFFFF ; inverse mask sep #0x20 ; 8-bit accumulator loop: txa ; put inverse mask into accumulator eor [srcptr],y ; get the byte and invert it sta [invertBuf],y ; store in the destination buffer iny cpy lineWidth ; done yet? bcc loop ; no... #if 0 txa ; prepare to fill in remainder of scan line loop2: cpy #160 ; at least 320 pixels wide? bcs done ; yes... sta [invertBuf],y ; else fill it in iny bra loop2 done: #endif rep #0x20 ; back to 16-bit accumulator } srcptr += lineWidth; /* update source pointer */ srcSize = lineWidth; /* # of bytes per scan line */ dummyBuf = invertBuf; /* use temporary pointer for PackBytes */ dstSize = PackBytes(&dummyBuf,&srcSize,dstptr,lineWidth); totalSize += dstSize; /* accumulate total size */ ScanLineDirectory[linenum].numBytes = dstSize; ScanLineDirectory[linenum].modeWord = RefPtr->portSCB; writeblk.requestCount = dstSize; WriteGS(&writeblk); if(errNum = /* assignment */ _toolErr) goto goodbye; /* messy, but efficient! */ if(!(++counter & 7)) { /* update the cursor every eighth scan line processed */ SetCursor(animCursor[++cursNum]); if(!(cursNum < 7)) /* in other words, if cursNum >= 7 (but this produces better code) */ cursNum = -1; } } setpositionblk.displacement = 0; /* set file mark to beginning of file */ SetMarkGS(&setpositionblk); if(errNum = /* assignment */ _toolErr) goto goodbye; /* messy, but efficient! */ picHeader.blkSize = totalSize; /* fill in header fields */ picHeader.pixPerLine = RefPtr->width << (RefPtr->portSCB ? 2 : 1); /* pixels per line */ picHeader.scanLines = numLines; /* # of lines in image */ picHeader.mscb = RefPtr->portSCB; /* master SCB */ /* get the pallette into the header */ memcpy(picHeader.pallette,cTable,sizeof(picHeader.pallette)); writeblk.requestCount = sizeof(infoBlockHdr); writeblk.dataBuffer = (Ptr) &picHeader; WriteGS(&writeblk); if(errNum = /* assignment */ _toolErr) goto goodbye; /* messy, but efficient! */ writeblk.requestCount = numLines * sizeof(dirEntry); writeblk.dataBuffer = (Ptr) ScanLineDirectory; WriteGS(&writeblk); if(errNum = /* assignment */ _toolErr) goto goodbye; /* messy, but efficient! */ CloseGS(&closeblk); errNum = _toolErr; goodbye: SetMasterSCB(oldSCB); /* reset master SCB */ closeblk.refNum = 0; /* do a global close */ CloseGS(&closeblk); goodbye2: free(invertBuf); free(dstptr); free(ScanLineDirectory); InitCursor(); return(errNum); } \ No newline at end of file diff --git a/scsi2/SCANNERSCSI.S b/scsi2/SCANNERSCSI.S new file mode 100644 index 0000000..2bf8413 --- /dev/null +++ b/scsi2/SCANNERSCSI.S @@ -0,0 +1,1307 @@ +* +* SCANNER SCSI +* A test app for SCSI scanner commands +* +* (c) 2024, Brutal Deluxe Software +* Visit brutaldeluxe.fr +* + + xc + xc + mx %00 + + rel + dsk SCANNERSCSI.l + lst off + +*---------- + + use 4/Int.Macs + use 4/Locator.Macs + use 4/Mem.Macs + use 4/Misc.Macs + use 4/Text.Macs + use 4/Util.Macs + +Debut = $00 +GSOS = $e100a8 + +*---------- + +devSCANNER = $001a + +maxDEVICES = 8 + +dcINQUIRY = $8012 +doMODESELECT = $8015 +dcMODESENSE6 = $801a +dcSTARTSTOP = $801b ; also eject/insert +dcGETWINDOW24 = $8024 ; for scanner +dcGETWINDOW25 = $8025 ; for scanner +dcREADCAPACITY = $8025 +dcSUBCHANNEL = $8042 +dcREADTOC = $8043 +dcPATI = $8048 +dcPAUSERESUME = $804b +dcMODESENSE10 = $805a + +*---------- + + phk + plb + + tdc + sta myDP + + _TLStartUp + pha + _MMStartUp + pla + sta appID + ora #$0100 + sta myID + + _MTStartUp + _TextStartUp + + _IMStartUp + + pha + pha + PushLong #$010000 + PushWord myID + PushWord #%11000000_00011100 + PushLong #0 + _NewHandle + phd + tsc + tcd + lda [3] + sta ptrBUFFER + ldy #2 + lda [3],y + sta ptrBUFFER+2 + pld + ply + sty haBUFFER + plx + stx haBUFFER+2 + +*---------- + + PushWord #$00FF + PushWord #$0080 + _SetInGlobals + PushWord #$00FF + PushWord #$0080 + _SetOutGlobals + PushWord #$00FF + PushWord #$0080 + _SetErrGlobals + + PushWord #0 + PushLong #3 + _SetInputDevice + PushWord #0 + PushLong #3 + _SetOutputDevice + PushWord #0 + PushLong #3 + _SetErrorDevice + + PushWord #0 + _InitTextDev + PushWord #1 + _InitTextDev + PushWord #2 + _InitTextDev + + PushWord #$0c ; home + _WriteChar + +* DEBUG + + lda #proSTATUS + stal $300 + lda #^proSTATUS + stal $302 + + lda #proCONTROL + stal $310 + lda #^proCONTROL + stal $312 + +*---------------------------- +* MAIN MENU +*---------------------------- + +mainMENU = * + + PushLong #strMAINMENU + _WriteCString + + jsr waitFORKEY + cmp #"Q" + beq doQUIT + cmp #"q" + beq doQUIT + cmp #"1" + bne mainMENU + + jmp searchMENU + +*--- Data + +strMAINMENU asc 0d'SCANNER SCSI'0d + asc '(c) 2024, Brutal Deluxe Software'0d + asc ' 1. Search for SCSI Scanners'0d + asc ' Q. Quit'0d00 + +*---------------------------- +* QUIT PROGRAM +*---------------------------- + +doQUIT = * + + _IMShutDown + _TextShutDown + _MTShutDown + + PushWord myID + _DisposeAll + + PushWord appID + _MMShutDown + + _TLShutDown + + jsl GSOS + dw $2029 + adrl proQUIT + + brk $bd + +*---------------------------- +* SEARCH MENU +*---------------------------- + +searchMENU = * + + PushLong #strSEARCHMENU + _WriteCString + + jsr pollCDSCSI ; show CD-ROM devices + +]lp jsr waitFORKEY ; is it 0-9 + cmp #"0" + bcc ]lp + bne searchMENU2 + jmp mainMENU ; or even 0 to exit +searchMENU2 cmp #"9"+1 + bcs ]lp + + sec ; we have our device ID + sbc #"0" + cmp nbDEVICES ; in the 1-nbDEVICES range + bcc searchMENU3 + bne ]lp + +searchMENU3 dec + asl + tax + lda tblDEVICES,x + sta theDEVICE ; we have our device now + jmp deviceMENU + +*---------- Routines + +pollCDSCSI stz nbDEVICES ; number of SCSI CD-ROM found + + lda #1 ; start with device 1 + sta proDINFO+2 + +]lp jsl GSOS ; do a DInfo + dw $202c + adrl proDINFO + bcc found + + cmp #$0011 ; no more devices + bne loop + rts + +loop inc proDINFO+2 + bra ]lp + +*---------- Check it is a scanner + +found lda proDINFO+20 ; not SCANNER + cmp #devSCANNER + bne loop + +*--- We have a scanner + + lda nbDEVICES + asl + tax + lda proDINFO+2 + sta tblDEVICES,x + + jsr showDEVICEINFO + + inc nbDEVICES + lda nbDEVICES + cmp #maxDEVICES + bcc loop ; loop again + rts + +*--- Sub routines +* +* x - $xxxx - .NAMEOFDEVICE + +showDEVICEINFO + pha ; from a word to a string + pha + pha + _HexIt + PullLong strDEVID + + PushWord #$20 ; space + _WriteChar + + lda nbDEVICES ; write device index + inc + ora #"0" + pha + _WriteChar + + PushLong #strDEV ; show the string + _WriteCString + + lda devINFO1 ; from a STRL to a STR + xba + sta devINFO1 + + PushLong #devINFO2 + _WriteString + + PushWord #$0d + _WriteChar + rts + +*---------- Data + +strDEV asc ' - $' +strDEVID asc '0000 - '00 + +nbDEVICES ds 2 ; number of devices +theDEVICE ds 2 ; the device to play with +tblDEVICES ds 16*2 ; we authorize 16 devices + +strSEARCHMENU + asc 0d'Searching for SCSI Scanners...'0d + asc ' 0. Go back to previous menu'0d00 + +*---------------------------- +* DEVICE MENU +*---------------------------- + +deviceMENU = * + + lda theDEVICE ; get our ID + sta proSTATUS+2 + sta proCONTROL+2 + + pha ; from a word to a string + pha + pha + _HexIt + PullLong strDEVMENU + + PushLong #strDEVICEMENU + _WriteCString + +*--- + +]lp jsr waitFORKEY ; is it 0-9 + cmp #"0" + bcc ]lp + bne deviceMENU2 + jmp searchMENU ; or even 0 to exit +deviceMENU2 cmp #"5"+1 + bcs ]lp + + sec ; call the routines + sbc #"1" + asl + tax + lda ptrCOMMANDS,x + sta deviceMENU3+1 +deviceMENU3 jsr $bdbd + jmp deviceMENU + +ptrCOMMANDS da doINQUIRY + da doGWP2424 + da doGWP2425 + da doGWP2524 + da doGWP2525 + +*--- Data + +strDEVICEMENU asc 0d'Using SCSI Scanner device $' +strDEVMENU asc '0000'0d + asc ' 0. Go back to previous menu'0d + asc ' 1. Inquiry'0d + asc ' 2. Get Window Parameters 24/24'0d + asc ' 3. Get Window Parameters 24/25'0d + asc ' 4. Get Window Parameters 25/24'0d + asc ' 5. Get Window Parameters 25/25'0d + asc 00 + +*---------------- +* SCSI COMMANDS +*---------------- + +doINQUIRY = * + + jsr initSTATUSDATA + + ldx #6-2 ; put the inquiry data +]lp lda scsiINQUIRY,x + sta statusDATA,x + dex + dex + bpl ]lp + + lda #dcINQUIRY + jsr statusCALL + bcc doINQUIRY1 + rts + +doINQUIRY1 + +*--- Display data + +* Byte 0 + + PushLong #strPQ + _WriteCString + + lda statusBUFF + and #%11100000 + xba + ldx #3 + jsr showBITS + + PushLong #strPDT + _WriteCString + + lda statusBUFF + and #%00011111 + asl + asl + asl + xba + ldx #5 + jsr showBITS + +* Byte 1 + + PushLong #strRMB + _WriteCString + + lda statusBUFF+1 + and #%10000000 + xba + ldx #1 + jsr showBITS + + PushLong #strDTM + _WriteCString + + lda statusBUFF+1 + and #%01111111 + asl + xba + ldx #7 + jsr showBITS + +* Byte 2 + + PushLong #strISO + _WriteCString + + lda statusBUFF+2 + and #%11000000 + xba + ldx #2 + jsr showBITS + + PushLong #strECMA + _WriteCString + + lda statusBUFF+2 + and #%00111000 + asl + asl + xba + ldx #3 + jsr showBITS + + PushLong #strANSI + _WriteCString + + lda statusBUFF+2 + and #%00000111 + asl + asl + asl + asl + asl + xba + ldx #3 + jsr showBITS + +* Byte 3 + + PushLong #strAENC + _WriteCString + + lda statusBUFF+3 + and #%10000000 + xba + ldx #1 + jsr showBITS + + PushLong #strTRMIOP + _WriteCString + + lda statusBUFF+3 + and #%01000000 + asl + xba + ldx #1 + jsr showBITS + + PushLong #strRDF + _WriteCString + + lda statusBUFF+3 + and #%00001111 + asl + asl + asl + asl + xba + ldx #4 + jsr showBITS + +* Bytes 4..6 not used + +* Byte 7 + + PushLong #strRELADR + _WriteCString + + lda statusBUFF+7 + and #%10000000 + xba + ldx #1 + jsr showBITS + + PushLong #strWBUS32 + _WriteCString + + lda statusBUFF+7 + and #%01000000 + asl + xba + ldx #1 + jsr showBITS + + PushLong #strWBUS16 + _WriteCString + + lda statusBUFF+7 + and #%00100000 + asl + asl + xba + ldx #1 + jsr showBITS + + PushLong #strSYNC + _WriteCString + + lda statusBUFF+7 + and #%00010000 + asl + asl + asl + xba + ldx #1 + jsr showBITS + + PushLong #strLINKED + _WriteCString + + lda statusBUFF+7 + and #%00001000 + asl + asl + asl + asl + xba + ldx #1 + jsr showBITS + + PushLong #strCMDQUE + _WriteCString + + lda statusBUFF+7 + and #%00000010 + asl + asl + asl + asl + asl + asl + xba + ldx #1 + jsr showBITS + + PushLong #strSFTRE + _WriteCString + + lda statusBUFF+7 + and #%00000001 + asl + asl + asl + asl + asl + asl + asl + xba + ldx #1 + jsr showBITS + +* Bytes 8 + + PushLong #strVI + _WriteCString + + lda #8 ; offset is 8 + tax ; length is 8 + jsr showTEXT + +* Bytes 16 + + PushLong #strPI + _WriteCString + + lda #16 + tax + jsr showTEXT + +* Bytes 32 + + PushLong #strPRL + _WriteCString + + lda #32 + ldx #4 + jsr showTEXT + + jmp waitKEY + +*--- Data + +scsiINQUIRY hex 12,00,00,00,00,00 + +strPQ asc 0d' Peripheral qualifier: '00 +strPDT asc ' - Peripheral device type : '00 +strRMB asc 0d' RMB: '00 +strDTM asc ' - Device-type modifier: '00 +strISO asc 0d' ISO version: '00 +strECMA asc ' - ECMA version: '00 +strANSI asc ' - ANSI-approved version: '00 +strAENC asc 0d' AENC: '00 +strTRMIOP asc ' - TrmIOP: '00 +strRDF asc ' - Response data format: '00 +strRELADR asc 0d' RelAdr: '00 +strWBUS32 asc ' - WBus32: '00 +strWBUS16 asc ' - WBus16: '00 +strSYNC asc ' - Sync: '00 +strLINKED asc 0d' Linked: '00 +strCMDQUE asc ' - CmdQue: '00 +strSFTRE asc ' - SftRe: '00 +strVI asc 0d' Vendor identification: '00 +strPI asc 0d' Product identification: '00 +strPRL asc 0d' Product revision level: '00 + +*---------------- + +doGWP2424 lda #dcGETWINDOW24 + ldx #$24 + bra doGETWINDOW + +doGWP2425 lda #dcGETWINDOW24 + ldx #$25 + bra doGETWINDOW + +doGWP2524 lda #dcGETWINDOW25 + ldx #$24 + bra doGETWINDOW + +doGWP2525 lda #dcGETWINDOW25 + ldx #$25 + +doGETWINDOW sta doGETWIN0+1 + sep #$10 + stx scsiGETWIN + rep #$10 + + jsr initSTATUSDATA + + ldx #10-2 ; put the getwindow data +]lp lda scsiGETWIN,x + sta statusDATA,x + dex + dex + bpl ]lp + +doGETWIN0 lda #dcGETWINDOW24 + jsr statusCALL + bcc doGETWINDOW1 + rts + +doGETWINDOW1 + +*--- Check response length + + lda #statusBUFF + clc + adc #8 + sta Debut + lda #^statusBUFF + adc #0 + sta Debut+2 + +*--- Display Window identifier + + PushLong #strGWID + _WriteCString + + ldy #0 + lda [Debut],y + xba + jsr showBYTE + +*--- Display X-Axis resolution + + PushLong #strGWXRES + _WriteCString + + ldy #2 + lda [Debut],y + xba + jsr showWORD + +*--- Display Y-Axis resolution + + PushLong #strGWYRES + _WriteCString + + ldy #4 + lda [Debut],y + xba + jsr showWORD + +*--- Display X-Axis upper left + + PushLong #strGWXUL + _WriteCString + + ldy #6 + lda [Debut],y + xba + jsr showWORD + ldy #8 + lda [Debut],y + xba + jsr showWORD + +*--- Display Y-Axis upper left + + PushLong #strGWYUL + _WriteCString + + ldy #10 + lda [Debut],y + xba + jsr showWORD + ldy #12 + lda [Debut],y + xba + jsr showWORD + +*--- Display Window width + + PushLong #strGWWW + _WriteCString + + ldy #14 + lda [Debut],y + xba + jsr showWORD + ldy #16 + lda [Debut],y + xba + jsr showWORD + +*--- Display Window length + + PushLong #strGWWL + _WriteCString + + ldy #18 + lda [Debut],y + xba + jsr showWORD + ldy #20 + lda [Debut],y + xba + jsr showWORD + +*--- Display Brightness + + PushLong #strGWBR + _WriteCString + + ldy #22 + lda [Debut],y + jsr showBYTE + +*--- Display Threshold + + PushLong #strGWTH + _WriteCString + + ldy #23 + lda [Debut],y + jsr showBYTE + +*--- Display Contrast + + PushLong #strGWCO + _WriteCString + + ldy #24 + lda [Debut],y + jsr showBYTE + +*--- Display Image composition + + PushLong #strGWIC + _WriteCString + + ldy #25 + lda [Debut],y + and #$ff + pha + jsr showBYTE + pla + cmp #6+1 + bcc okGWIC + lda #6 +okGWIC asl + tax + + lda #^strGWIC00 + pha + lda ptrGWIC,x + pha + _WriteCString + +*--- Display Bits per pixel + + PushLong #strGWBPP + _WriteCString + + ldy #26 + lda [Debut],y + jsr showBYTE + +*--- Display Halftone pattern + + PushLong #strGWHP + _WriteCString + + ldy #27 + lda [Debut],y + xba + jsr showWORD + +*--- Display Padding type + + PushLong #strGWPT + _WriteCString + + ldy #29 + lda [Debut],y + and #%00000111 + cmp #4+1 + bcc okGWPT + lda #4 +okGWPT asl + tax + + lda #^strGWPT00 + pha + lda ptrGWPT,x + pha + _WriteCString + +*--- Display Bit ordering + + PushLong #strGWBO + _WriteCString + + ldy #30 + lda [Debut],y + xba + jsr showWORD + +*--- Display Compression type + + PushLong #strGWCT + _WriteCString + + ldy #32 + lda [Debut],y + and #$ff + cmp #$10+1 + bcc okGWCT + lda #$10 +okGWCT asl + tax + + lda #^strGWCT00 + pha + lda ptrGWCT,x + pha + _WriteCString + +*--- Display Compression argument + + PushLong #strGWCA + _WriteCString + + ldy #33 + lda [Debut],y + jsr showBYTE + +*--- We're done + + jmp waitKEY + +*--- Data + +scsiGETWIN hex 25,00,00,00,00,00,00,00,00,00 + +strGWID asc 0d'Window identifier: $'00 +strGWXRES asc 0d'X-Axis resolution: $'00 +strGWYRES asc 0d'Y-axis resolution: $'00 +strGWXUL asc 0d'X-Axis upper left: $'00 +strGWYUL asc 0d'Y-Axis upper left: $'00 +strGWWW asc 0d'Window width: $'00 +strGWWL asc 0d'Window length: $'00 +strGWBR asc 0d'Brightness: $'00 +strGWTH asc 0d'Threshold: $'00 +strGWCO asc 0d'Contrast: $'00 +strGWIC asc 0d'Image composition: $'00 +strGWBPP asc 0d'Bits per pixel: $'00 +strGWHP asc 0d'Halftone pattern: $'00 +strGWPT asc 0d'Padding type: $'00 +strGWBO asc 0d'Bit ordering: $'00 +strGWCT asc 0d'Compression type: $'00 +strGWCA asc 0d'Compression argument: $'00 + +ptrGWIC da strGWIC00 + da strGWIC01 + da strGWIC02 + da strGWIC03 + da strGWIC04 + da strGWIC05 + da strGWIC06 + +strGWIC00 asc ' (Bi-level black & white)'00 +strGWIC01 asc ' (Dithered/halftone black & white)'00 +strGWIC02 asc ' (Multi-level black & white (gray scale))'00 +strGWIC03 asc ' (Bi-level RGB colour)'00 +strGWIC04 asc ' (Dithered/halftone RGB colour)'00 +strGWIC05 asc ' (Multi-level RGB colour)'00 +strGWIC06 asc ' (Reserved)'00 + +ptrGWPT da strGWPT00 + da strGWPT01 + da strGWPT02 + da strGWPT03 + da strGWPT04 + +strGWPT00 asc ' (No boundary)'00 +strGWPT01 asc ' (Pad with 0s to byte boundary)'00 +strGWPT02 asc ' (Pad with 1s to byte boundary)'00 +strGWPT03 asc ' (Truncate by byte boundary)'00 +strGWPT04 asc ' (Reserved)'00 + +ptrGWCT da strGWCT00 + da strGWCT01 + da strGWCT02 + da strGWCT03 + da strGWCT04 + da strGWCT04 + da strGWCT04 + da strGWCT04 + da strGWCT04 + da strGWCT04 + da strGWCT04 + da strGWCT04 + da strGWCT04 + da strGWCT04 + da strGWCT04 + da strGWCT04 + da strGWCT10 + +strGWCT00 asc ' (No compression)'00 +strGWCT01 asc ' (CCITT group III, 1 dimensional)'00 +strGWCT02 asc ' (CCITT group III, 2 dimensional)'00 +strGWCT03 asc ' (CCITT group IV, 2 dimensional)'00 +strGWCT04 asc ' (Reserved)'00 +strGWCT10 asc ' (Optical character recognition)'00 + +*--- SCSI routines + +initSTATUSDATA ; clear SCSI command buffer + ldx #12-2 +]lp stz statusDATA,x + dex + dex + bpl ]lp + rts + +initCOMMANDDATA ; clear SCSI command buffer + ldx #12-2 +]lp stz commandDATA,x + dex + dex + bpl ]lp + rts + +*--- DStatus +* Uses the DStatus parm buffer + +statusCALL sta proSTATUS+4 ; SCSI driver command + sep #$20 ; SCSI commands are 8-bit + sta statusDATA ; SCSI command + rep #$20 + + jsl GSOS ; call it + dw $202d + adrl proSTATUS + bra showERR + +*--- DControl + +controlCALL sta proCONTROL+4 ; SCSI driver command + sep #$20 ; SCSI commands are 8-bit + sta commandDATA ; SCSI command + rep #$20 + + jsl GSOS ; call it + dw $202e + adrl proCONTROL + +*--- Show GS/OS error code + +showERR bcc showNOERR + sta errCODE ; save error code + + PushLong #strERROR + _WriteCString + + lda errCODE + jsr showWORD ; display it + + PushWord #$0d + _WriteChar + sec ; force carry +showNOERR rts + +*---------------------------- +* TEXT ROUTINES +*---------------------------- + +*---------- Display in string offset +* A: offset in +* X: nb of chars to print +* offset from commandBUFF + +showTEXT ldy #^commandBUFF + phy + clc + adc #commandBUFF + pha + PushWord #0 + phx + _TextWriteBlock + rts + +*---------- Display decimal +* A: word + +showDECIMAL and #$ff + pha + + lda #' ' ; space by default + sta strDECIMAL + + PushLong #strDECIMAL + PushWord #2 + PushWord #0 + _Int2Dec + + PushLong #strDECIMAL + _WriteCString + rts + +*--- Data + +strDECIMAL asc '00'00 + +*---------- Display bits +* A: word +* X: nb of bits to display (1-8) + +showBITS cpx #16 + bcc showBITS0 + rts + +showBITS0 ldy #0 ; index +]lp pha + asl ; bit in carry + bcs showBITS1 + + lda #'00' ; output 0 + bra showBITS2 +showBITS1 lda #'11' ; output 1 +showBITS2 sta strBITS,y + + pla + asl + iny + dex + bne ]lp + + lda #0 ; end C string + sta strBITS,y + + PushLong #strBITS ; show the string + _WriteCString + rts + +*--- Data + +strBITS ds 18 ; 16 bits + 2 zeros + +*---------- Display a byte + +showBYTE pha ; from a byte to a string + pha + pha ; <= here, really + _HexIt + + lda #' ' ; empty string by default + sta strBYTE + + pla ; we don't use + pla + sta strBYTE + + PushLong #strBYTEP ; show the string + _WriteString + rts + +*--- Data + +strBYTEP dfb 2 ; for a Pascal string +strBYTE asc ' ' + +*---------- Display a word + +showWORD pha ; from a word to a string + pha + pha ; <= here, really + _HexIt + PullLong strHEX + + PushLong #strHEX ; show the string + _WriteCString + rts + +*--- Data + +strHEX asc '0000'00 + +*---------- Wait for a key in a range 0-Acc +* A: high key +* X: high ptr to C string +* Y: low ptr to C string + +keyINRANGE sta keyHIGH + sty strKEY + stx strKEY+2 + +]lp PushLong strKEY + _WriteCString + + PushWord #0 + PushWord #1 ; echo char + _ReadChar + pla + and #$ff + cmp #"0" + bcc ]lp + cmp keyHIGH + bcc keyINRANGE9 + beq keyINRANGE9 + bra ]lp + +keyINRANGE9 sec + sbc #"0" + pha + bra waitKEY8 + +*--- Data + +strKEY ds 4 ; pointer to string +keyHIGH ds 2 + +*---------- Wait for a key + +waitKEY PushWord #$0d + _WriteChar + + PushWord #0 + PushWord #0 ; don't echo char + _ReadChar + bra waitKEY1 ; go below + +*---------- Wait for a key + +waitFORKEY PushLong #strINPUT + _WriteCString + + PushWord #0 ; wait for key + PushWord #1 ; echo char + _ReadChar + +waitKEY1 lda 1,s ; check CR + and #$ff ; of typed + sta 1,s ; in char + cmp #$8d + beq waitKEY9 + +waitKEY8 PushWord #$0d ; return + _WriteChar + +waitKEY9 pla ; restore entered char + rts + +*--- Data + +strINPUT asc 'Select an entry: '00 + +*---------------------------- +* DATA +*---------------------------- + +errCODE ds 2 ; GS/OS error code +strERROR asc 0d' GS/OS error code $'00 + +*--- + +proQUIT dw 2 ; pcount + ds 4 ; pathname + ds 2 ; flags + +proDINFO dw 8 ; Parms for DInfo + ds 2 ; 02 device num + adrl devINFO ; 04 device name + ds 2 ; 08 characteristics + ds 4 ; 0A total blocks + ds 2 ; 0E slot number + ds 2 ; 10 unit number + ds 2 ; 12 version + ds 2 ; 14 device id + +devINFO dw $0032 ; buffer size +devINFO1 db $00 ; length +devINFO2 db $00 +devINFO3 ds $30 ; data + +proSTATUS dw 5 ; 00 pcount + ds 2 ; 02 device num + dw $8000 ; 04 status/control code + adrl statusLIST ; 06 status list + adrl 1024 ; 0A request count + ds 4 ; 0E transfer count + +statusLIST ds 2 ; always 0000 +statusDATA hex 00 ; 00 + hex 00 ; 01 + hex 00 ; 02 + hex 00 ; 03 + hex 00 ; 04 + hex 00 ; 05 + hex 00 ; 06 + hex 00 ; 07 + hex 00 ; 08 + hex 00 ; 09 + hex 00 ; 10 + hex 00 ; 11 + adrl statusBUFF +statusBUFF ds 1234 ; more than 1024 + +proCONTROL dw 5 ; 00 pcount + ds 2 ; 02 device num + dw $8000 ; 04 status/control code + adrl controlLIST ; 06 status list + adrl 1024 ; 0A request count + ds 4 ; 0E transfer count + +controlLIST ds 2 ; always 0000 +commandDATA hex 00 ; 00 + hex 00 ; 01 + hex 00 ; 02 + hex 00 ; 03 + hex 00 ; 04 + hex 00 ; 05 + hex 00 ; 06 + hex 00 ; 07 + hex 00 ; 08 + hex 00 ; 09 + hex 00 ; 10 + hex 00 ; 11 +commandPTR adrl commandBUFF +commandBUFF ds 1234 ; more than 1024 + +*---------- + +appID ds 2 +myID ds 2 + +myDP ds 2 +ptrBUFFER ds 4 +haBUFFER ds 4 +