antoine-source/scsi2/AppleScanGS/Scanner.GSOS.aii
Antoine Vignau fae5db3afd scsi-2 powa!
2024-08-15 21:27:35 +02:00

1 line
26 KiB
Plaintext
Raw Blame History

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, <20>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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,$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