Accessing FOSSIL from BAS

 BBS: Inland Empire Archive
Date: 02-14-93 (21:39)             Number: 309
From: CORIDON HENSHAW              Refer#: NONE
  To: ALL                           Recvd: NO  
Subj: Accessing FOSSIL from BAS      Conf: (2) Quik_Bas
Hello All!

Thought this may be of use to someone here.

===Chop=== BEGIN COMM.BAS  PROJECT: SirrusMail(0)
DECLARE FUNCTION FossInit% (Port%)
DECLARE FUNCTION BlockRead$ (Port%)
DECLARE FUNCTION BlockWrite% (Port%, Buffer$)
DEFINT A-Z

'$INCLUDE: 'QBX.BI'

FUNCTION BlockRead$ (Port)
Buffer$ = STRING$(32766, 0) 'Max 32766 bytes to read
Regs.CX = LEN(Buffer$)
Regs.DX = Port
Regs.ES = SSEG(Buffer$)
Regs.DI = SADD(Buffer$)
CALL InterruptX(&H14, Regs, Regs)
BlockRead$ = LEFT$(Buffer$, Regs.AX)
END FUNCTION

FUNCTION BlockWrite (Port, Buffer$)
Regs.CX = LEN(Buffer$)
Regs.DX = Port
Regs.ES = SSEG(Buffer$)
Regs.DI = SADD(Buffer$)
CALL InterruptX(&H14, Regs, Regs)
BlockWrite = Regs.AX 'Number of chars transfered
END FUNCTION

SUB FossDeInit (Port)
' Release the FOSSIL device driver
Regs.AX = &H500
Regs.DX = Port
InterruptX &H14, Regs, Regs
END SUB

FUNCTION FossInit (Port)

' Initialize the FOSSIL device driver
'
' dx = Communications port number (0-3)
' ah = &H04    Fossil Function Number - Initialize FOSSIL driver
'                                       (Raises DTR in the porcess)

Regs.DX = Port
Regs.AX = &H400
CALL InterruptX(&H14, Regs, Regs)

IF Regs.AX <> &H1954 THEN
   FossInit = False 'Fossil Not Found
END IF

FossInit = True

END FUNCTION

SUB SetDtr (Port, DtrStatus)
Regs.DX = Port 'Set carrier detect low or high
SELECT CASE DtrStatus
    CASE 0
    Regs.AX = &H600
    CASE 1
    Regs.AX = &H601
    CASE ELSE
    Regs.AX = &H600
    BEEP
END SELECT
InterruptX &H14, Regs, Regs
END SUB

SUB SetFlowControl (Port, Control)
Regs.DX = Port
SELECT CASE Control
 CASE 1 'Xon/Xoff on transmit
  Regs.AX = &H601
 CASE 2 'CTS/RTS
  Regs.AX = &H602
 CASE 3 'Xon/Xoff on recieve
  Regs.AX = &H608
END SELECT
CALL InterruptX(&H14, Regs, Regs)
END SUB

SUB SetPortParams (Port, Bps AS LONG, Bits, Stops, Parity$)
Regs.DX = Port
Regs.AX = 0
SELECT CASE Bps
    CASE 300
    Regs.AX = (Regs.AX OR &H40)
    CASE 600
    Regs.AX = (Regs.AX OR &H60)
    CASE 1200
    Regs.AX = (Regs.AX OR &H80)
    CASE 2400
    Regs.AX = (Regs.AX OR &HA0)
    CASE 4800
    Regs.AX = (Regs.AX OR &HC0)
    CASE 9600
    Regs.AX = (Regs.AX OR &HE0)
    CASE 19200
    Regs.AX = (Regs.AX OR &H0)
    CASE 38400
    Regs.AX = (Regs.AX OR &H20)
    CASE ELSE
    Regs.AX = (Regs.AX OR &HA0)
    'Default to 2400 baud
END SELECT

SELECT CASE Bits
    CASE 5
    Regs.AX = (Regs.AX OR &H0)
    CASE 6
    Regs.AX = (Regs.AX OR &H1)
    CASE 7
    Regs.AX = (Regs.AX OR &H2)
    CASE 8
    Regs.AX = (Regs.AX OR &H3)
    CASE ELSE
    Regs.AX = (Regs.AX OR &H3)
    'Default to 8 bits
END SELECT

SELECT CASE Stops
    CASE 1
    Regs.AX = (Regs.AX OR &H0)
    CASE 2
    Regs.AX = (Regs.AX OR &H4)
    CASE ELSE
    Regs.AX = (Regs.AX OR &H0)
    'Default to 1 stop bit
END SELECT

SELECT CASE UCASE$(Parity$)
    CASE "N"
    Regs.AX = (Regs.AX OR &H0)
    CASE "O"
    Regs.AX = (Regs.AX OR &H8)
    CASE "E"
    Regs.AX = (Regs.AX OR &H18)
    CASE ELSE
    Regs.AX = (Regs.AX OR &H0)
    ' Default to no parity
END SELECT
Regs.DX = Port
InterruptX &H14, Regs, Regs
END SUB
===Chop=== END COMM.BAS  LINE: 149
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET