Simple door 3/4

 BBS: Inland Empire Archive
Date: 02-06-93 (09:42)             Number: 343
From: DAVID COLSTON                Refer#: NONE
  To: ALL                           Recvd: NO  
Subj: Simple door           3/4      Conf: (2) Quik_Bas
>>> Continued from previous message
SUB GetChar (Port, Good, InBound$, Present, Reg AS RegType)
CheckPortStatus Port, Info, Reg ' Test for space in OUTPUT buffer
IF NOT Present THEN
                InBound$ = INKEY$
                IF InBound$ > "" THEN
                        Good = -1
                ELSE
                        Good = 0
                END IF
                EXIT SUB
END IF
IF (Info AND &H4) = 0 THEN
        IF (Info AND &H2) = &H2 THEN
                Reg.ax = &H200
                Reg.dx = Port
                Interrupt &H14, Reg, Reg
                InBound$ = CHR$(Reg.ax)
                Good = -1
        ELSE
                Good = 0' No Characters in input buffer
                InBound$ = INKEY$
                IF InBound$ > "" THEN Good = -1
        END IF
ELSE ' Input buffer over-run
        Good = 0
        Reg.ax = &HA00
        Reg.dx = Port
        Interrupt &H14, Reg, Reg
        BEEP
END IF
END SUB

SUB PrintCon (A$, Reg AS RegType) STATIC
IF A$ = "" THEN EXIT SUB
        Reg.ax = &H600
        Reg.dx = ASC(A$)
        Interrupt &H21, Reg, Reg
        IF A$ = CHR$(13) THEN
                Reg.ax = &H600
                Reg.dx = 10
                Interrupt &H21, Reg, Reg
        END IF
END SUB

SUB SendChar (Port, Sent, Present, Outbound$, Reg AS RegType)
A! = TIMER
IF NOT Present THEN
        Sent = 0
        EXIT SUB
END IF
DO
        CheckPortStatus Port, Info, Reg ' room in buffer ?
        IF (Reg.ax AND &H80) = 0 THEN
                Sent = -1
                EXIT DO
        END IF
    IF (Info AND &H10) = 0 THEN
           Reg.dx = Port
           Reg.ax = &H100 + ASC(Outbound$)
           Interrupt &H14, Reg, Reg
           Sent = -1
        END IF
LOOP WHILE NOT Sent AND TIMER - A! < 2
IF Sent = 0 AND Reg.ax AND &H80 <> 0 THEN
    Sent = 0 ' Output buffer full
    Reg.ax = &H900
    Reg.dx = Port
    Interrupt &H14, Reg, Reg
END IF
END SUB

SUB SetDtr (Port, DtrStatus$, Reg AS RegType)
Reg.dx = Port 'Set carrier detect low or high
SELECT CASE UCASE$(DtrStatus$)
    CASE "L"
    Reg.ax = &H600
    CASE "H"
    Reg.ax = &H601
    CASE ELSE
    Reg.ax = &H600
    BEEP
END SELECT
Interrupt &H14, Reg, Reg
END SUB

SUB SetHandShake (Port, HandShake, Reg AS RegType)
Reg.dx = Port
IF HandShake > &HF THEN
    HandShake = &H2
    'Set handshake to RTS/CTS.
    BEEP
END IF
Reg.ax = &HF00 + HandShake
Interrupt &H14, Reg, Reg
Reg.ax = &H1000
Reg.dx = Port
Interrupt &H14, Reg, Reg
END SUB

SUB SetPortParams (Port, Baud$, Bits, Stops, Parity$, Reg AS RegType)
Reg.dx = Port
Reg.ax = 0
SELECT CASE Baud$
    CASE "300"
    Reg.ax = (Reg.ax OR &H40)
    CASE "600"
    Reg.ax = (Reg.ax OR &H60)
    CASE "1200"
    Reg.ax = (Reg.ax OR &H80)
    CASE "2400"
    Reg.ax = (Reg.ax OR &HA0)
    CASE "4800"
    Reg.ax = (Reg.ax OR &HC0)
    CASE "9600"
    Reg.ax = (Reg.ax OR &HE0)
    CASE "19200"
    Reg.ax = (Reg.ax OR &H0)
    CASE "38400"
    Reg.ax = (Reg.ax OR &H20)
    CASE ELSE
    Reg.ax = (Reg.ax OR &HA0)
    'Default to 2400 baud
END SELECT

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

SELECT CASE Stops
    CASE 1
    Reg.ax = (Reg.ax OR &H0)
    CASE 2
    Reg.ax = (Reg.ax OR &H4)
    CASE ELSE
    Reg.ax = (Reg.ax OR &H0)
    'Default to 1 stop bit
END SELECT
>>> Continued to next message
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