' These are SHADOW bindings for GFA BASIC - GFA BASIC is copyright Michtron
'
' ==========================================================================
'
'    You may freely distribute and use this section of code within
'    your program.  However, the SHADOW program and desk accessory is
'    copyrighted material and may not be copied or distributed
'    under penalty of US copyright laws.  SHADOW is a registered trademark
'    of Antic Publishing, Inc.
'
'
'    ----------------SHADOW record--------------
'
'    Shadow_vars     - Block count
'    Shadow_vars+2   - Status of SHADOW
'    Shadow_vars+4   - Received bytes
'    Shadow_vars+8   - Bytes to send
'    Shadow_vars+12  - Number of files to send (for Y-Batch)
'    Shadow_vars+14  - File sizes for Y-Batch (Array of 32 Long values)
'    Shadow_vars+142 - Filenames for Y-Batch (Each filename should start
'          every 16 bytes.  Ex. filename1=Shadow_vars+142,
'          filename2=Shadow_vars+158) (array of 16 bytes by 32 names)
'
'    ***  (Read Only)  ***
'
'    Shadow_vars+654 - Digit flag 0=OFF,1=ON
'    Shadow_vars+656 - Bell flag  0=OFF,1=ON
'    Shadow_vars+658 - Mode currently used.  1=Receive,2=Send
'    Shadow_vars+660 - Type of transfer (Ex. 3=Ascii)
'    Shadow_vars+662 - Dial flag  0=Not dialing,1=dialing in progress
'
'    --------------------------------------------
'
'    Note:  It is very easy to save and load the SHADOW buffer with
'     all the protocol's except Y-Batch.  This is because you
'     can receive or send one or more files.  So here are a few tips:
'
'     For Y-Batch receive -
'
'     Each file received will begin on a 128 byte boundary from buffer start
'     The number of files received will be in Shadow_vars+12
'     The file size will be in Shadow_vars+14,18,22...
'     The filename will be located in Shadow_vars+142,158,174...
'
'     For Y-Batch send -
'
'     Each file you send must begin on a 128 byte boundary from buffer start
'     Store the number of files to be sent at Shadow_vars+12
'     Store the file sizes beginning at Shadow_vars+14,18,22...
'     Store the filenames at Shadow_vars+142,158,174...
'     Start Y-Batch the same like the others.
'
'
'     SHADOW (C) 1988 Double Click Software
'
'
'    Initialize arrays to access SHADOW routines.  Which are used
'    during a 'Supexec' call to the BIOS.
'
Procedure Shadow_init
  '
  Shadow_routine1$=""
  Shadow_routine2$=""
  Shadow_routine3$=""
  Shadow_routine4$=""
  Shadow_routine5$=""
  Shadow_routine6$=""
  Aline_routine$=""
  Do
    Read Asm%
    Exit If Asm%<0
    Shadow_routine1$=Shadow_routine1$+Mki$(Asm%)
  Loop
  Do
    Read Asm%
    Exit If Asm%<0
    Shadow_routine2$=Shadow_routine2$+Mki$(Asm%)
  Loop
  Do
    Read Asm%
    Exit If Asm%<0
    Shadow_routine3$=Shadow_routine3$+Mki$(Asm%)
  Loop
  Do
    Read Asm%
    Exit If Asm%<0
    Shadow_routine4$=Shadow_routine4$+Mki$(Asm%)
  Loop
  Do
    Read Asm%
    Exit If Asm%<0
    Shadow_routine5$=Shadow_routine5$+Mki$(Asm%)
  Loop
  Do
    Read Asm%
    Exit If Asm%<0
    Shadow_routine6$=Shadow_routine6$+Mki$(Asm%)
  Loop
  Do
    Read Asm%
    Exit If Asm%<0
    Aline_routine$=Aline_routine$+Mki$(Asm%)
  Loop
Return
'
'    This procedure will check to see if SHADOW is present.
'
'    Shadow_temp = 0 if SHADOW is not present
'    Shadow_temp = 1 if SHADOW is present
'
Procedure Shadow_check
  Asm_code%=Varptr(Shadow_routine1$)
  Shadow_temp=Xbios(38,L:Asm_code%)
Return
'
'    This procedure will return the address of the SHADOW variables.
'
'    Shadow_vars = Points to SHADOW variables
'
Procedure Shadow_record
  Asm_code%=Varptr(Shadow_routine2$)
  Poke Asm_code%+3,0
  Shadow_vars=Xbios(38,L:Asm_code%)
Return
'
'    This procedure will abort a transfer.
'
Procedure Shadow_abort
  Asm_code%=Varptr(Shadow_routine2$)
  Poke Asm_code%+3,3
  Shadow_temp=Xbios(38,L:Asm_code%)
Return
'
'    Turn digits on/off.
'
Procedure Shadow_digits_on
  Asm_code%=Varptr(Shadow_routine2$)
  Poke Asm_code%+3,4
  Shadow_temp=Xbios(38,L:Asm_code%)
Return
'
Procedure Shadow_digits_off
  Asm_code%=Varptr(Shadow_routine2$)
  Poke Asm_code%+3,5
  Shadow_temp=Xbios(38,L:Asm_code%)
Return
'
'    Turn bell on/off.
'
Procedure Shadow_bell_on
  Asm_code%=Varptr(Shadow_routine2$)
  Poke Asm_code%+3,6
  Shadow_temp=Xbios(38,L:Asm_code%)
Return
'
Procedure Shadow_bell_off
  Asm_code%=Varptr(Shadow_routine2$)
  Poke Asm_code%+3,7
  Shadow_temp=Xbios(38,L:Asm_code%)
Return
'
'    This procedure will start receiving a file.  (Xmodem checksum)
'
Procedure Shadow_receive_xchecksum
  Asm_code%=Varptr(Shadow_routine3$)
  Poke Asm_code%+17,0
  Poke Asm_code%+21,1
  Shadow_temp=Xbios(38,L:Asm_code%)
Return
'
'    This procedure will start receiving a file.  (Xmodem CRC/CRC 1K)
'
Procedure Shadow_receive_xcrc
  Asm_code%=Varptr(Shadow_routine3$)
  Poke Asm_code%+17,1
  Poke Asm_code%+21,1
  Shadow_temp=Xbios(38,L:Asm_code%)
Return
'
'    This procedure will start receiving a file.  (Ascii)
'
Procedure Shadow_receive_ascii
  Asm_code%=Varptr(Shadow_routine3$)
  Poke Asm_code%+17,3
  Poke Asm_code%+21,1
  Shadow_temp=Xbios(38,L:Asm_code%)
Return
'
'    This procedure will start receiving a file.  (Y-Batch)
'
Procedure Shadow_receive_ybatch
  Asm_code%=Varptr(Shadow_routine3$)
  Poke Asm_code%+17,4
  Poke Asm_code%+21,1
  Shadow_temp=Xbios(38,L:Asm_code%)
Return
'
'    This procedure will start receiving a file.  (B-Protocol)
'
Procedure Shadow_receive_bproto
  Asm_code%=Varptr(Shadow_routine3$)
  Poke Asm_code%+17,5
  Poke Asm_code%+21,1
  Shadow_temp=Xbios(38,L:Asm_code%)
Return
'
'    This procedure will get the address of the SHADOW buffer.
'
Procedure Shadow_get_buffer
  Asm_code%=Varptr(Shadow_routine4$)
  Poke Asm_code%+9,16
  Shadow_buffer=Xbios(38,L:Asm_code%)
Return
'
'    This procedure will get the SHADOW buffer length.
'
Procedure Shadow_get_length
  Asm_code%=Varptr(Shadow_routine4$)
  Poke Asm_code%+9,2
  Shadow_length=Xbios(38,L:Asm_code%)
Return
'
'    This procedure will start sending a file.  (Xmodem checksum)
'
Procedure Shadow_send_xchecksum
  Asm_code%=Varptr(Shadow_routine5$)
  Lpoke Asm_code%+8,Length
  Poke Asm_code%+19,0
  Poke Asm_code%+23,2
  Shadow_temp=Xbios(38,L:Asm_code%)
Return
'
'    This procedure will start sending a file.  (Xmodem CRC/CRC 1K)
'
Procedure Shadow_send_xcrc
  Asm_code%=Varptr(Shadow_routine5$)
  Lpoke Asm_code%+8,Length
  Poke Asm_code%+19,1
  Poke Asm_code%+23,2
  Shadow_temp=Xbios(38,L:Asm_code%)
Return
'
'    This procedure will start sending a file.  (Ascii)
'
Procedure Shadow_send_ascii
  Asm_code%=Varptr(Shadow_routine5$)
  Lpoke Asm_code%+8,Length
  Poke Asm_code%+19,3
  Poke Asm_code%+23,2
  Shadow_temp=Xbios(38,L:Asm_code%)
Return
'
'    This procedure will start sending a file.  (Y-Batch)
'
Procedure Shadow_send_ybatch
  Asm_code%=Varptr(Shadow_routine5$)
  Lpoke Asm_code%+8,Length
  Poke Asm_code%+19,4
  Poke Asm_code%+23,2
  Shadow_temp=Xbios(38,L:Asm_code%)
Return
'
'    This procedure will start sending a file.  (B-Protocol)
'
Procedure Shadow_send_bproto
  Asm_code%=Varptr(Shadow_routine5$)
  Lpoke Asm_code%+8,Length
  Poke Asm_code%+19,5
  Poke Asm_code%+23,2
  Shadow_temp=Xbios(38,L:Asm_code%)
Return
'
'    Dial using SHADOW.
'
'    Example:
'
'    If Dpeek(Shadow_vars+662)=0
'   @Shadow_dial("ATDT1234567","CONNECT","NO","BUSY")
'    Else
'   @Shadow_dial_abort
'    Endif
'
Procedure Shadow_dial(Dial$,Connect$,Fail1$,Fail2$)
  Asm_code%=Varptr(Shadow_routine6$)
  Lpoke Asm_code%+20,Varptr(Dial$)
  Lpoke Asm_code%+14,Varptr(Connect$)
  Lpoke Asm_code%+8,Varptr(Fail1$)
  Lpoke Asm_code%+2,Varptr(Fail2$)
  Void Xbios(38,L:Asm_code%)
Return
'
'    Abort SHADOW dial.
'
Procedure Shadow_dial_abort
  Asm_code%=Varptr(Shadow_routine6$)
  Lpoke Asm_code%+20,0
  Void Xbios(38,L:Asm_code%)
Return
'
'    Disassembled Machine code for SHADOW Access
'
Data 28672,8313,0,1070,45564,64,0,26376,3152,220,26114,28673,20085
Data -1
Data 16188,0,20047,21647,20085
Data -1
Data 8313,0,1070,12072,2,12072,16,16188,0,16188,1,20047,57340,0,12,20085
Data -1
Data 8313,0,1070,8232,2,20085
Data -1
Data 8313,0,1070,12092,0,0,12072,16,16188,0,16188,1,20047,57340,0,12,20085
Data -1
Data 12092,0,0,12092,0,0,12092,0,0,12092,0,0,16188,9,20047,57340,0,18,20085
Data -1
'
'    This is the call to find the ALINE variable for number of text
'    lines the screen can have.
'
Data 40960,37372,0,42,8200,20085
Data -1
' ==========================================================================
