'**** This contains the Verb Functionality files
DEFINT A-Z

DECLARE SUB AddPronoun (b$)
DECLARE FUNCTION VerbThrow% (b$)
DECLARE FUNCTION VerbSpray% (b$)
DECLARE FUNCTION VerbMove% (b$)
DECLARE FUNCTION VerbSit% (b$)
DECLARE FUNCTION VerbTurn% (b$)
DECLARE FUNCTION VerbBuy% (b$)
DECLARE SUB SetRoomPic (lo%)
DECLARE FUNCTION VerbInsert% (b$)
DECLARE FUNCTION VerbRepair% (b$)
DECLARE FUNCTION GetUo$ (x, y)
DECLARE FUNCTION HasDirection% (b$)
DECLARE FUNCTION GetMaxItems% ()
DECLARE FUNCTION GetOc$ (x%)
DECLARE FUNCTION GetObject% (x%)
DECLARE FUNCTION GetSpecial! (x%)
DECLARE SUB SetObject (x%, y%)
DECLARE SUB SetSpecial (x%, y!)
DECLARE FUNCTION GetResource$ (lo, tag$)
DECLARE FUNCTION IsVerb% (t$, b$)

DECLARE FUNCTION IsColor% (a$)
DECLARE FUNCTION IsPrep% (b$, prep$)
DECLARE FUNCTION IsNoun% (b$, noun$)
DECLARE FUNCTION IsItem% (a$, Itemno%)
DECLARE SUB AddLine (WhichArray%, Text$, ResetColors%)
DECLARE SUB SetDirections (lo%)
DECLARE SUB AskExitGame (b$, whicht)
DECLARE FUNCTION VerbPress% (b$)
DECLARE FUNCTION VerbInject% (b$)
DECLARE FUNCTION VerbWear% (b$)
DECLARE FUNCTION VerbGive% (b$)
DECLARE FUNCTION VerbOpen% (b$)
DECLARE FUNCTION VerbUnlock% (b$)
DECLARE FUNCTION VerbUnplug% (b$)
DECLARE FUNCTION VerbDrink% (b$)
DECLARE FUNCTION VerbPour% (b$)
DECLARE FUNCTION VerbPut% (b$)
DECLARE FUNCTION VerbGet% (b$)
DECLARE FUNCTION VerbLook% (b$)
DECLARE FUNCTION VerbEat% (b$)
DECLARE FUNCTION VerbTalk% (b$)
DECLARE FUNCTION VerbInventory% (a$)
DECLARE FUNCTION VerbLookAtItems% (a$)
DECLARE FUNCTION VerbGetDrop% (a$)
DECLARE FUNCTION GetCanHold ()

CONST MAXARRAYSIZE = 60

COMMON SHARED TextMode
COMMON SHARED BwMode   'configurable
COMMON SHARED MusicOn
COMMON SHARED SoundOn
COMMON SHARED AllUpper 'configurable
COMMON SHARED Box1Size 'This is set by code, not configurable
COMMON SHARED Box2Size 'This is set by code, not configurable
COMMON SHARED a$
COMMON SHARED lo AS INTEGER
COMMON SHARED Fbuff AS STRING * 8960 'For Fonts
COMMON SHARED ScrollArray() AS STRING * 96
COMMON SHARED bs1$, bs2$, bs3$, bs4$, bs5$, bs6$, bs0$, bsb$

DIM SHARED ScrollArray(MAXARRAYSIZE, 1 TO 2) AS STRING * 96

FUNCTION VerbBuy (b$)

IF IsVerb(b$, "BUY") = 0 THEN EXIT FUNCTION 'Wasn't trying to talk after all

a$ = UCASE$(b$)

IF lo = 9 THEN
    AddLine 2, GetResource$(lo, "NOBUY"), 1
    VerbBuy = 1: EXIT FUNCTION
END IF

IF lo = 10 THEN
    AddLine 2, GetResource$(lo, "NOBUY"), 1
    VerbBuy = 1: EXIT FUNCTION
END IF

END FUNCTION

FUNCTION VerbDrink (b$)

IF IsVerb(b$, "DRINK") = 0 THEN EXIT FUNCTION 'Wasn't trying to talk after all

a$ = UCASE$(b$)
IF (IsItem(a$, 1) OR (IsNoun(a$, "WATER") AND GetSpecial(1) > 0)) AND GetObject(1) = 0 THEN
    IF GetSpecial(1) = 0 THEN AddLine 2, GetResource$(0, "DRINKWATER0"), 1
    IF GetSpecial(1) = 1 THEN
        AddLine 2, GetResource$(0, "DRINKWATER1"), 1
        AskExitGame b$, 1
    END IF
    IF GetSpecial(1) = 2 THEN
        SetSpecial 1, 0
        AddLine 2, GetResource$(0, "DRINKWATER2"), 1
    END IF
    IF GetSpecial(1) = 3 THEN AddLine 2, GetResource$(0, "DRINKWATER3"), 1
    IF GetSpecial(1) = 4 THEN
        SetSpecial 1, 0
        AddLine 2, GetResource$(0, "DRINKWATER4"), 1
    END IF
    VerbDrink = 1: EXIT FUNCTION
END IF

VerbDrink = 0

END FUNCTION

FUNCTION VerbEat (b$)

IF IsVerb(b$, "EAT") = 0 THEN EXIT FUNCTION 'Wasn't trying to talk after all

a$ = UCASE$(b$)

IF IsItem(a$, 11) AND GetObject(11) = 0 THEN
    AddLine 2, GetResource$(0, "EATSALT"), 1
    VerbEat = 1: EXIT FUNCTION
END IF

IF IsItem(a$, 15) AND GetObject(15) = 0 THEN
    AddLine 2, GetResource$(0, "EATSOUP"), 1
    AskExitGame b$, 1
    VerbEat = 1: EXIT FUNCTION
END IF

IF IsItem(a$, 16) AND GetObject(16) = 0 THEN
    AddLine 2, GetResource$(0, "EATPOTATO"), 1
    AskExitGame b$, 1
    VerbEat = 1: EXIT FUNCTION
END IF

IF IsItem(a$, 3) AND GetObject(3) = 0 THEN
    IF lo <> 21 THEN
        AddLine 2, GetResource$(0, "NOEATPILL"), 1
        VerbEat = 1: EXIT FUNCTION
    END IF
    IF GetObject(1) <> 0 OR GetSpecial(1) <> 2 THEN
        AddLine 2, GetResource$(lo, "CHOKEONPILL"), 1
        AskExitGame b$, 1
        VerbEat = 1: EXIT FUNCTION
    END IF
    AddLine 2, GetResource$(lo, "EATPILL"), 1
    SetSpecial 1, 0: SetObject 4, 0: SetObject 3, 101: SetSpecial 2, 3
    VerbEat = 1: EXIT FUNCTION
END IF

VerbEat = 0

END FUNCTION

FUNCTION VerbGet (b$)

IF IsVerb(b$, "GET") = 0 THEN EXIT FUNCTION 'Wasn't trying to talk after all

a$ = UCASE$(b$)

IF lo = 17 THEN
    IF GetSpecial(22) = 1 AND IsItem(a$, 17) THEN
        IF GetObject(17) = 0 THEN
            AddLine 2, GetResource$(lo, "GETGLOB1"), 1
            VerbGet = 1: EXIT FUNCTION
        END IF
        IF GetObject(1) = 0 THEN
            IF GetSpecial(1) = 3 THEN
                AddLine 2, GetResource$(lo, "GETGLOB2"), 1
                'take butter from tray and put it into inventory.
                SetSpecial 22, 0: SetObject 17, 0
                VerbGet = 1: EXIT FUNCTION
            END IF
            AddLine 2, GetResource$(lo, "GETGLOB3"), 1
            'Butter is wasted now.
            SetSpecial 22, 0
            VerbGet = 1: EXIT FUNCTION
        ELSE
            AddLine 2, GetResource$(lo, "GETGLOB4"), 1
            'Butter is wasted now.
            SetSpecial 22, 0
            VerbGet = 1: EXIT FUNCTION
        END IF
    END IF
END IF

IF lo = 27 THEN
    IF IsNoun(a$, "WATER") AND IsVerb(a$, "ENTER") = 0 THEN
        IF INSTR(a$, " WITH ") < 3 AND INSTR(a$, " IN ") < 3 AND INSTR(a$, " USING ") < 3 AND INSTR(a$, " INTO ") < 3 THEN
            AddLine 2, GetResource$(lo, "GETWATER1"), 1
            VerbGet = 1: EXIT FUNCTION
        END IF
        x = IsItem(b$, 0)
        IF x <> 1 OR GetObject(x) <> 0 THEN
            AddLine 2, GetResource$(lo, "GETWATER2"), 1
            VerbGet = 1: EXIT FUNCTION
        END IF
        '*** Let's find out if they still have water in the cup.
        IF GetSpecial(1) = 0 THEN
            IF GetSpecial(18) = 0 THEN SetSpecial 1, 1 'Fill cup with hot
            IF GetSpecial(18) = 1 THEN SetSpecial 1, 2 'Fill cup with cold
            AddLine 2, GetResource$(lo, "GETWATER3"), 1
            VerbGet = 1: EXIT FUNCTION
        END IF
        AddLine 2, GetResource$(lo, "GETWATER4"), 1
        VerbGet = 1: EXIT FUNCTION
    END IF
END IF

IF lo = 36 THEN
    IF IsNoun(a$, "WATER") AND IsVerb(a$, "ENTER") = 0 THEN
        IF INSTR(a$, " WITH ") < 3 AND INSTR(a$, " IN ") < 3 AND INSTR(a$, " USING ") < 3 AND INSTR(a$, " INTO ") < 3 THEN
            AddLine 2, GetResource$(lo, "GETWATER1"), 1
            VerbGet = 1: EXIT FUNCTION
        END IF
        x = IsItem(b$, 0)
        IF x <> 1 OR GetObject(x) <> 0 THEN
            AddLine 2, GetResource$(27, "GETWATER2"), 1
            VerbGet = 1: EXIT FUNCTION
        END IF
        '*** Let's find out if they still have water in the cup.
        IF GetSpecial(1) = 0 THEN
            SetSpecial 1, 1 'Fill cup with hot
            AddLine 2, GetResource$(lo, "GETWATER2"), 1
            VerbGet = 1: EXIT FUNCTION
        END IF
        AddLine 2, GetResource$(27, "GETWATER4"), 1
        VerbGet = 1: EXIT FUNCTION
    END IF
END IF


END FUNCTION

FUNCTION VerbGetDrop (a$)

a$ = UCASE$(a$)
HasItems = 0
Warned = 0
Rc = 1

FOR x = 1 TO GetMaxItems
    IF GetObject(x) = 0 THEN HasItems = HasItems + 1
NEXT x

v = 0: g = 0'Gotten anything?
IF IsVerb(a$, "GET") THEN
    FOR x = 1 TO GetMaxItems
        IF RIGHT$(a$, 4) <> " ALL" AND INSTR(a$, " ALL ") = 0 AND INSTR(a$, "EVERYTH") = 0 THEN
            FOR y = 1 TO 5
                IF GetObject(x) = lo AND INSTR(a$, GetUo$(x, y)) THEN
                    IF HasItems >= GetCanHold THEN
                        IF Warned = 0 THEN
                            AddLine 2, "`2You're holding as many items as you can. Drop something first.", Rc
                            Warned = 1: Rc = 0: v = 1
                        END IF
                    ELSE
                        g = 1: HasItems = HasItems + 1
                        AddLine 2, "`2You pick up the `0" + GetOc$(x) + "`7.", Rc
                        AddPronoun (GetUo$(x, y))
                        SetObject x, 0: Rc = 0
                    END IF
                END IF
            NEXT y
        END IF
        IF RIGHT$(a$, 4) = " ALL" OR INSTR(a$, " ALL ") OR INSTR(a$, "EVERYTH") THEN
            IF GetObject(x) = lo THEN
                IF HasItems >= GetCanHold THEN
                    IF Warned = 0 THEN
                        AddLine 2, "`2You're holding as many items as you can. Drop something first.", Rc
                        Warned = 1: Rc = 0: v = 1
                    END IF
                ELSE
                    g = 1: HasItems = HasItems + 1
                    AddLine 2, "`2You pick up the `0" + GetOc$(x) + "`7.", Rc
                    AddPronoun (GetUo$(x, 1))
                    SetObject x, 0: Rc = 0
                END IF
            END IF
        END IF
    NEXT x
END IF

IF g <> 0 OR v <> 0 THEN VerbGetDrop = 1: EXIT FUNCTION

g = 0 'Dropped anything?

IF IsVerb(a$, "DROP") THEN
    FOR x = 1 TO GetMaxItems
        IF RIGHT$(a$, 4) <> " ALL" AND INSTR(a$, " ALL ") = 0 AND INSTR(a$, "EVERYTH") = 0 THEN
            Ndrop = 0
            FOR y = 1 TO 5
                IF GetObject(x) = 0 AND INSTR(a$, GetUo$(x, y)) THEN
                    g = 1
                    IF Ndrop = 0 THEN
                        IF (lo = 31 AND x = 8) THEN
                            AddLine 2, GetResource$(38, "NODROPX1") + GetOc$(x) + "`2 here.", Rc
                            Rc = 0: Ndrop = 1
                        END IF
                        IF lo = 34 AND x = 10 AND GetSpecial(14) = 0 THEN
                            AddLine 2, GetResource$(38, "NODROPX1") + GetOc$(x) + "`2 here. " + GetResource$(38, "NODROPX2"), Rc
                            Rc = 0: Ndrop = 1
                        END IF
                    END IF
                    IF Ndrop = 0 THEN
                        b$ = "`2You drop the `0" + GetOc$(x) + "`2 here."
                        AddPronoun (GetUo$(x, y))
                        IF x = 1 AND (GetSpecial(1) = 1 OR GetSpecial(1) = 2 OR GetSpecial(1) = 4) THEN
                            SetSpecial 1, 0: b$ = b$ + " It spills."
                        END IF
                        IF x = 1 AND GetSpecial(1) = 3 THEN
                           IF GetObject(17) = 0 THEN
                               SetObject 17, 100: b$ = b$ + " The ice spills out and the butter melts."
                           ELSE
                              SetSpecial 1, 0: b$ = b$ + " The ice spills out."
                           END IF
                        END IF
                        IF x = 10 THEN SetSpecial 13, 0 'No longer wearing the tray
                        IF x = 8 THEN SetSpecial 12, 0 'No longer wearing welder's goggles
                        IF x = 17 THEN
                            b$ = b$ + " It melts away."
                        END IF
                        AddLine 2, b$, Rc
                        SetObject x, lo: Rc = 0
                        IF x = 17 THEN SetObject x, 100 'Butter is GONE now!
                    END IF
                END IF
            NEXT y
        END IF
        IF RIGHT$(a$, 4) = " ALL" OR INSTR(a$, " ALL ") OR INSTR(a$, "EVERYTH") THEN
            IF GetObject(x) = 0 THEN
                g = 1: Ndrop = 0
                IF (lo = 31 AND x = 8) THEN
                    AddLine 2, GetResource$(38, "NODROPX1") + GetOc$(x) + "`2 here.", Rc
                    Rc = 0: Ndrop = 1
                END IF
                IF lo = 34 AND x = 10 AND GetSpecial(14) = 0 THEN
                    AddLine 2, GetResource$(38, "NODROPX1") + GetOc$(x) + "`2 here. " + GetResource$(38, "NODROPX2"), Rc
                    Rc = 0: Ndrop = 1
                END IF
                IF Ndrop = 0 THEN
                    b$ = "`2You drop the `0" + GetOc$(x) + "`2 here."
                    AddPronoun (GetUo$(x, 1))
                    IF x = 1 AND (GetSpecial(1) = 1 OR GetSpecial(1) = 2 OR GetSpecial(1) = 4) THEN
                        SetSpecial 1, 0: b$ = b$ + " It spills."
                    END IF
                    IF x = 1 AND GetSpecial(1) = 3 THEN
                        IF GetObject(17) = 0 THEN
                            SetObject 17, 100: b$ = b$ + " The ice spills out and the butter melts."
                        ELSE
                           SetSpecial 1, 0: b$ = b$ + " The ice spills out."
                        END IF
                    END IF
                    IF x = 10 THEN SetSpecial 13, 0 'No longer wearing the tray
                    IF x = 8 THEN SetSpecial 12, 0 'No longer wearing welder's goggles
                    AddLine 2, b$, Rc
                    SetObject x, lo: Rc = 0
                END IF
            END IF
        END IF
    NEXT x
END IF

IF g <> 0 THEN VerbGetDrop = 1: EXIT FUNCTION

END FUNCTION

FUNCTION VerbGive (b$)

IF IsVerb(b$, "GIVE") = 0 THEN EXIT FUNCTION 'Wasn't trying to talk after all

a$ = UCASE$(b$)

IF lo = 5 THEN
    IF IsNoun(a$, "KANDI") THEN
        IF IsItem(a$, 7) AND GetObject(7) = 0 THEN
            SetObject 7, 102
            AddLine 2, GetResource$(lo, "GIVEVAL"), 1
            VerbGive = 1: EXIT FUNCTION
        END IF
    END IF
END IF

IF lo = 7 THEN
    IF IsNoun(a$, "TODD") THEN
        IF IsItem(a$, 7) AND GetObject(7) = 0 THEN
            SetObject 7, 101
            AddLine 2, GetResource$(lo, "GIVEVAL"), 1
            VerbGive = 1: EXIT FUNCTION
        END IF
    END IF
END IF

IF lo = 9 THEN
    IF IsNoun(a$, "SOCRATES") THEN
        IF IsItem(a$, 14) AND GetObject(14) = 0 THEN
            SetObject 14, 101: 'Get rid of the water gun now.
            SetObject 16, 0:  'Give them the rotten potato
            AddLine 2, GetResource$(lo, "GIVEGUN"), 1
            VerbGive = 1: EXIT FUNCTION
        END IF
    END IF
END IF

IF lo = 10 THEN
    IF IsNoun(a$, "NAPOLEON") THEN
        IF IsItem(a$, 10) AND GetObject(10) = 0 THEN
            SetObject 10, 101: 'Get rid of the tray now.
            SetObject 5, 0:  'Give them some crazy bucks
            SetSpecial 10, 300: 'They now have 300 crazy bucks
            AddLine 2, GetResource$(lo, "GIVETRAY"), 1
            VerbGive = 1: EXIT FUNCTION
        END IF
    END IF
END IF

IF lo = 15 THEN
    IF IsNoun(a$, "SANDY") THEN
        IF IsItem(a$, 11) AND GetObject(11) = 0 THEN
            IF (GetSpecial(25) AND 2) > 0 THEN
                AddLine 2, GetResource$(lo, "GAVESALT"), 1
                VerbGive = 1: EXIT FUNCTION
            ELSE
                SetSpecial 25, GetSpecial(25) + 2
                a1$ = GetResource$(lo, "GIVESALT")
                GOTO CheckForSoup
            END IF
        END IF
        IF IsItem(a$, 17) AND GetObject(17) = 0 THEN
            IF (GetSpecial(25) AND 1) > 0 THEN
                AddLine 2, GetResource$(lo, "GAVEBUTTER"), 1
                VerbGive = 1: EXIT FUNCTION
            ELSE
                SetSpecial 25, GetSpecial(25) + 1
                SetObject 17, 100 'Butter is now gone. could make more, but no need.
                a1$ = GetResource$(lo, "GIVEBUTTER")
                GOTO CheckForSoup
            END IF
        END IF
        IF IsItem(a$, 16) AND GetObject(16) = 0 THEN
            IF (GetSpecial(25) AND 4) > 0 THEN
                AddLine 2, GetResource$(lo, "GAVEPOTATO"), 1
                VerbGive = 1: EXIT FUNCTION
            ELSE
                SetSpecial 25, GetSpecial(25) + 4
                SetObject 16, 101 'Butter is now gone. could make more, but no need.
                a1$ = GetResource$(lo, "GIVEPOTATO")
                GOTO CheckForSoup
            END IF
        END IF
        IF IsItem(a$, 5) AND GetObject(5) = 0 AND GetSpecial(10) >= 300 THEN
            IF (GetSpecial(25) AND 8) > 0 THEN
                AddLine 2, GetResource$(lo, "GAVEMONEY"), 1
                VerbGive = 1: EXIT FUNCTION
            ELSE
                SetSpecial 25, GetSpecial(25) + 8
                SetObject 5, 103 'Money is now given to lady.
                SetSpecial 10, 0 'No more money now.
                a1$ = GetResource$(lo, "GIVEMONEY")
                GOTO CheckForSoup
            END IF
        END IF
    END IF
END IF

IF lo = 21 THEN
    IF IsNoun(a$, "JESUS") AND GetSpecial(17) = 0 THEN
        IF IsItem(a$, 15) AND GetObject(15) = 0 THEN
            SetObject 15, 101 'Get rid of the soup now
            SetObject 20, lo
            AddLine 2, GetResource$(lo, "DROPNAPKIN"), 1
            VerbGive = 1: EXIT FUNCTION
        END IF
    END IF
END IF

IF lo = 28 THEN
    IF IsItem(a$, 2) AND GetObject(2) = 0 THEN
        IF IsNoun(a$, "GORDON") THEN
            AddLine 2, GetResource$(lo, "CIGTOMAN"), 1
            VerbGive = 1: EXIT FUNCTION
        END IF
        IF IsNoun(a$, "JENKINS") THEN
            AddLine 2, GetResource$(lo, "CIGTOWOMAN"), 1
            SetSpecial 5, 1: SetObject 2, 101
            VerbGive = 1: EXIT FUNCTION
        END IF
        IF IsNoun(a$, "GUARD") THEN
            AddLine 2, GetResource$(lo, "WHICHGUARD"), 1
            VerbGive = 1: EXIT FUNCTION
        END IF
    END IF
    IF IsItem(a$, 5) AND GetObject(5) = 0 AND GetSpecial(10) > 0 THEN
        IF IsNoun(a$, "JENKINS") THEN
            AddLine 2, GetResource$(lo, "CBNOWOMAN"), 1
            VerbGive = 1: EXIT FUNCTION
        END IF
        IF IsNoun(a$, "GORDON") THEN
            IF GetSpecial(10) = 100 THEN
                AddLine 2, GetResource$(lo, "CBTOMAN1"), 1
                SetSpecial 10, 0: SetObject 5, 101: SetSpecial 6, 1
                VerbGive = 1: EXIT FUNCTION
            END IF
            IF GetSpecial(10) = 200 THEN
                AddLine 2, GetResource$(lo, "CBTOMAN2"), 1
                SetSpecial 10, 0: SetObject 5, 102: SetSpecial 7, 1
                VerbGive = 1: EXIT FUNCTION
            END IF
        END IF
        IF IsNoun(a$, "GUARD") THEN
            AddLine 2, GetResource$(lo, "WHICHGUARD"), 1
            VerbGive = 1: EXIT FUNCTION
        END IF
    END IF
END IF

EXIT FUNCTION

CheckForSoup:
IF GetSpecial(25) >= 15 THEN
    SetObject 15, 0
    a1$ = a1$ + " " + GetResource$(lo, "GETSOUP")
END IF
AddLine 2, a1$, 1
VerbGive = 1: EXIT FUNCTION

END FUNCTION

FUNCTION VerbInject (b$)

IF IsVerb(b$, "INJECT") = 0 THEN EXIT FUNCTION 'Wasn't trying to talk after all

a$ = UCASE$(b$)

IF (IsItem(a$, 12) OR LEFT$(a$, 5) = "GIVE ") AND GetObject(12) = 0 THEN
    IF GetSpecial(15) = 0 THEN
        AddLine 2, GetResource$(0, "NOINJECT"), 1
        VerbInject = 1: EXIT FUNCTION
    END IF
    IF lo = 34 THEN
        IF IsNoun(a$, "CHUCK") THEN
            IF GetSpecial(15) = 1 AND GetSpecial(14) = 0 THEN
                SetSpecial 15, 0: SetSpecial 14, 1
                AddLine 2, GetResource$(lo, "INJECTION"), 1
                VerbInject = 1: EXIT FUNCTION
            END IF
        END IF
    END IF
END IF

END FUNCTION

FUNCTION VerbInsert (b$)

IF IsVerb(b$, "INSERT") = 0 THEN EXIT FUNCTION 'Wasn't trying to talk after all
a$ = UCASE$(b$)

IF IsItem(a$, 9) AND GetObject(9) = 0 AND IsItem(a$, 8) AND GetObject(8) = 0 THEN
    SetObject 9, 101 'Lose the lens
    AddLine 2, GetResource$(0, "FIXGOG"), 1
    VerbInsert = 1: EXIT FUNCTION
END IF
IF IsItem(a$, 13) AND GetObject(13) = 0 AND IsItem(a$, 8) AND GetObject(8) = 0 AND GetObject(9) <> 101 THEN
    AddLine 2, GetResource$(0, "NOFIXGOG"), 1
    VerbInsert = 1: EXIT FUNCTION
END IF

END FUNCTION

FUNCTION VerbMove (b$)

IF IsVerb(b$, "MOVE") = 0 THEN EXIT FUNCTION 'Wasn't trying to talk after all
a$ = UCASE$(b$)

IF lo = 13 THEN
    IF IsNoun(a$, "STATUE") THEN
        IF GetSpecial(24) = 0 THEN
            IF GetSpecial(29) = 1 THEN
                SetSpecial 24, 1: SetDirections (lo): SetRoomPic lo
                AddLine 2, GetResource$(lo, "OPENWALL1"), 1
            ELSE
                AddLine 2, GetResource$(lo, "OPENWALL2"), 1
            END IF
            VerbMove = 1: EXIT FUNCTION
        END IF
    END IF
END IF

END FUNCTION

FUNCTION VerbPour (b$)

IF IsVerb(b$, "POUR") = 0 THEN EXIT FUNCTION 'Wasn't trying to talk after all

a$ = UCASE$(b$)

IF lo = 17 AND IsNoun(a$, "APPARATUS") THEN
    IF GetObject(1) = 0 AND (IsItem(a$, 1) OR INSTR(a$, "WATER") OR (INSTR(a$, "SALT") AND GetSpecial(1) = 4)) THEN
        IF GetObject(19) <> 101 THEN
            AddLine 2, GetResource$(lo, "NOPOUR2"), 1
        ELSE
            IF GetSpecial(22) > 0 THEN
                AddLine 2, GetResource$(lo, "NOPOUR1"), 1
            ELSE
                IF GetSpecial(1) <> 4 THEN
                    AddLine 2, GetResource$(lo, "NOPOUR3"), 1
                ELSE
                    '** Otherwise, pour salt in, butter comes out!
                    AddLine 2, GetResource$(lo, "POUR1"), 1
                    SetSpecial 22, 1: SetSpecial 1, 0: 'Add Butter, remove water.
                END IF
            END IF
        END IF
        VerbPour = 1: EXIT FUNCTION
    END IF
END IF

IF (IsItem(a$, 1) OR (INSTR(a$, "WATER") AND (GetSpecial(1) = 1 OR GetSpecial(1) = 2 OR GetSpecial(1) = 4)) OR (INSTR(a$, "ICE") AND GetSpecial(1) = 3)) AND GetObject(1) = 0 THEN
    IF GetSpecial(1) = 0 THEN
        AddLine 2, GetResource$(0, "POURCUP1"), 1
        VerbPour = 1: EXIT FUNCTION
    END IF
    IF GetSpecial(1) = 1 OR GetSpecial(1) = 2 OR GetSpecial(1) = 4 THEN
        SetSpecial 1, 0
        AddLine 2, GetResource$(0, "POURCUP2"), 1
        VerbPour = 1: EXIT FUNCTION
    END IF
    IF GetSpecial(1) = 3 THEN
        SetSpecial 1, 0
        IF GetObject(17) = 0 THEN
            SetObject 17, 100 'Get rid of butter, if any
            AddLine 2, GetResource$(0, "POURCUP4"), 1
        ELSE
            AddLine 2, GetResource$(0, "POURCUP3"), 1
        END IF
        VerbPour = 1: EXIT FUNCTION
    END IF
END IF

IF IsItem(a$, 11) AND GetObject(11) = 0 THEN
    IF lo = 18 AND IsNoun(a$, "SQUID") AND GetSpecial(8) = 0 THEN
        SetSpecial 8, 1: SetDirections lo: SetRoomPic lo
        AddLine 2, GetResource$(lo, "POURSALT"), 1
        VerbPour = 1: EXIT FUNCTION
    END IF
    AddLine 2, GetResource$(0, "WASTESALT"), 1
    VerbPour = 1: EXIT FUNCTION
END IF

VerbPour = 0

END FUNCTION

FUNCTION VerbPress (b$)

IF IsVerb(b$, "PRESS") = 0 THEN EXIT FUNCTION 'Wasn't trying to talk after all
a$ = UCASE$(b$)

IF lo = 20 THEN
    IF IsNoun(a$, "PANEL") THEN
        AddLine 2, GetResource$(lo, "PUSHPANEL"), 1
        IF GetObject(19) = 100 THEN SetObject 19, lo
        VerbPress = 1: EXIT FUNCTION
    END IF
    IF IsNoun(a$, "BUTTON") OR IsNoun(a$, "#") THEN
        IF INSTR(a$, STR$(GetSpecial(20))) THEN 'Hot Tub Floor
            IF GetSpecial(21) = 2 THEN
                AddLine 2, GetResource$(lo, "FLOOR2"), 1
            ELSE
                SetSpecial 21, 2: SetDirections (lo)
                AddLine 2, GetResource$(lo, "GOFLOOR2"), 1
            END IF
            VerbPress = 1: EXIT FUNCTION
        END IF
        IF RIGHT$(a$, 2) = " 1" OR INSTR(a$, " 1 ") OR RIGHT$(a$, 3) = " 1." OR RIGHT$(a$, 3) = " #1" THEN
            IF GetSpecial(21) = 1 THEN
                AddLine 2, GetResource$(lo, "FLOOR1"), 1
            ELSE
                SetSpecial 21, 1: SetDirections (lo)
                AddLine 2, GetResource$(lo, "GOFLOOR1"), 1
            END IF
            VerbPress = 1: EXIT FUNCTION
        END IF
        '*** We can't go to that floor!
        IF IsNoun(a$, "#") THEN
            AddLine 2, GetResource$(lo, "NOFLOOR1"), 1
            VerbPress = 1: EXIT FUNCTION
        END IF
        '** Otherwise it's not even the right floor!
        AddLine 2, GetResource$(lo, "NOFLOOR2"), 1
        VerbPress = 1: EXIT FUNCTION
    END IF
END IF

IF lo = 24 THEN
    IF IsNoun(a$, "BUTTON") OR IsNoun(a$, "#") THEN
        IF GetSpecial(27) = 0 THEN
            IF INSTR(a$, STR$(GetSpecial(26))) AND GetSpecial(43) = 1 THEN 'Got The Code Right
                SetSpecial 27, 1: SetDirections (lo)
                SetRoomPic lo
                AddLine 2, GetResource$(lo, "ODOOR1"), 1
            ELSE
                AddLine 2, GetResource(lo, "ODOOR3"), 1
            END IF
        ELSE
            AddLine 2, GetResource$(lo, "ODOOR2"), 1
        END IF
        VerbPress = 1: EXIT FUNCTION
    END IF
END IF

IF lo = 30 THEN
    x = IsColor(a$)
    IF x >= 1 AND x <= 6 THEN
        IF GetObject(9) = 100 THEN
            a1$ = LTRIM$(STR$(GetSpecial(11))) 'The combination
            IF GetSpecial(16) < 1 THEN
                a2$ = ""
            ELSE
                a2$ = LTRIM$(STR$(GetSpecial(16))) 'What's been tried.
            END IF
            a2$ = a2$ + LTRIM$(STR$(x))
            IF RIGHT$(a2$, 1) <> MID$(a1$, LEN(a2$), 1) THEN
                '*** Not the right one, so let's silently reset!
                IF LEFT$(a1$, 1) = LTRIM$(STR$(x)) THEN
                    a2$ = LTRIM$(STR$(x))
                ELSE
                    a2$ = "0"
                    SetSpecial 16, 0 'Otherwise start over blank!
                END IF
            END IF
            SetSpecial 16, VAL(a2$) 'Start over with this starting color
            '**** Let's check to see if we got the WHOLE CODE RIGHT!
            IF LEN(a2$) >= 6 THEN
                SetObject 9, lo: SetSpecial 16, 0
                AddLine 2, GetResource$(lo, "CODEDONE"), 1
                VerbPress = 1: EXIT FUNCTION
            END IF
            AddLine 2, GetResource$(lo, "TOUCH" + LTRIM$(STR$(x))), 1
            VerbPress = 1: EXIT FUNCTION
        ELSE
            AddLine 2, GetResource$(lo, "NOTOUCH"), 1
            VerbPress = 1: EXIT FUNCTION
        END IF
    END IF
END IF

END FUNCTION

FUNCTION VerbPut (b$)

IF IsVerb(b$, "PUT") = 0 THEN EXIT FUNCTION 'Wasn't trying to talk after all

a$ = UCASE$(b$)
IF lo = 22 THEN
    IF (IsItem(a$, 1) OR IsNoun(a$, "WATER")) AND GetObject(1) = 0 AND IsNoun(a$, "FRIDGE") THEN
        IF IsPrep(a$, "INSIDE") THEN
            IF GetSpecial(1) = 0 THEN
                AddLine 2, GetResource$(lo, "PUTCUP1"), 1
                VerbPut = 1: EXIT FUNCTION
            END IF
            IF GetSpecial(1) = 4 THEN
                AddLine 2, GetResource$(lo, "PUTCUP6"), 1
                VerbPut = 1: EXIT FUNCTION
            END IF
            IF GetSpecial(1) = 1 AND GetSpecial(3) = 1 THEN
                SetSpecial 1, 2
                AddLine 2, GetResource$(lo, "PUTCUP2"), 1
                VerbPut = 1: EXIT FUNCTION
            END IF
            IF GetSpecial(1) = 1 AND GetSpecial(3) = 0 THEN
                SetSpecial 1, 3
                AddLine 2, GetResource$(lo, "PUTCUP3"), 1
                VerbPut = 1: EXIT FUNCTION
            END IF
            IF GetSpecial(1) = 2 THEN
                SetSpecial 1, 3
                AddLine 2, GetResource$(lo, "PUTCUP4"), 1
                VerbPut = 1: EXIT FUNCTION
            END IF
            IF GetSpecial(1) = 3 THEN
                AddLine 2, GetResource$(lo, "PUTCUP5"), 1
                VerbPut = 1: EXIT FUNCTION
            END IF
        END IF
    END IF
END IF

'***** Check to see if we're mixing SALT with WATER.

IF (IsItem(a$, 1) OR IsNoun(a$, "WATER")) AND GetObject(1) = 0 THEN
    IF IsItem(a$, 11) AND GetObject(11) = 0 THEN
        IF GetSpecial(1) = 0 THEN
            AddLine 2, GetResource$(0, "NOMIX1"), 1
            VerbPut = 1: EXIT FUNCTION
        END IF
        IF GetSpecial(1) = 3 THEN
            AddLine 2, GetResource$(0, "NOMIX2"), 1
            VerbPut = 1: EXIT FUNCTION
        END IF
        IF GetSpecial(1) = 4 THEN
            AddLine 2, GetResource$(0, "NOMIX3"), 1
            VerbPut = 1: EXIT FUNCTION
        END IF
        IF GetSpecial(1) = 1 THEN
            SetSpecial 1, 4
            AddLine 2, GetResource$(0, "SALTMIX1"), 1
            VerbPut = 1: EXIT FUNCTION
        END IF
        IF GetSpecial(1) = 2 THEN
            AddLine 2, GetResource$(0, "NOMIX4"), 1
            VerbPut = 1: EXIT FUNCTION
        END IF
    END IF
END IF

END FUNCTION

FUNCTION VerbRepair (b$)

IF IsVerb(b$, "REPAIR") = 0 THEN EXIT FUNCTION 'Wasn't trying to talk after all
a$ = UCASE$(b$)

IF IsItem(a$, 9) AND GetObject(9) = 0 AND IsItem(a$, 8) AND GetObject(8) = 0 THEN
    SetObject 9, 101 'Lose the lens
    AddLine 2, GetResource$(0, "FIXGOG"), 1
    VerbRepair = 1: EXIT FUNCTION
END IF
IF IsItem(a$, 13) AND GetObject(13) = 0 AND IsItem(a$, 8) AND GetObject(8) = 0 AND GetObject(9) <> 101 THEN
    AddLine 2, GetResource$(0, "NOFIXGOG"), 1
    VerbRepair = 1: EXIT FUNCTION
END IF

IF lo = 17 THEN
    IF IsItem(a$, 19) AND GetObject(19) = 0 THEN
        IF IsNoun(a$, "APPARATUS") THEN
            SetObject 19, 101 'Lose the gear
            AddLine 2, GetResource$(lo, "FIXAPP"), 1
            VerbRepair = 1: EXIT FUNCTION
        END IF
    END IF
END IF

END FUNCTION

FUNCTION VerbSit (b$)

IF IsVerb(b$, "SIT") = 0 THEN EXIT FUNCTION 'Wasn't trying to talk after all
a$ = UCASE$(b$)

IF lo = 25 THEN
    IF IsNoun(a$, "SHOCK") THEN
        IF GetSpecial(28) = 0 THEN
            AddLine 2, GetResource$(lo, "SITCHAIR1"), 1
            AskExitGame b$, 1
        ELSE
            IF GetSpecial(29) = 0 THEN
                SetSpecial 29, 1 'Give the player the Shock Strength
                AddLine 2, GetResource$(lo, "SITCHAIR2"), 1
            ELSE
                AddLine 2, GetResource$(lo, "SITCHAIR3"), 1
            END IF
        END IF
        VerbSit = 1: EXIT FUNCTION
    END IF
END IF

END FUNCTION

FUNCTION VerbSpray (b$)

x = 0
x = IsVerb(b$, "SPRAY")
IF x = 0 THEN x = IsVerb(b$, "KILL"): IF x <> 0 THEN x = 2
IF x = 0 THEN EXIT FUNCTION 'Wasn't trying to spray after all

a$ = UCASE$(b$)

IF lo = 8 THEN
    IF GetSpecial(34) = 0 AND IsNoun(a$, "BUGS") THEN
        IF GetObject(22) <> 0 THEN
            AddLine 2, GetResource$(lo, "NOSPRAY1"), 1
        ELSE
            '** Otherwise we've killed them!
            AddLine 2, GetResource$(lo, "SPRAY1"), 1
            SetSpecial 34, 1: SetRoomPic lo
        END IF
        VerbSpray = 1: EXIT FUNCTION
    END IF
END IF

END FUNCTION

FUNCTION VerbThrow (b$)

IF IsVerb(b$, "THROW") = 0 THEN EXIT FUNCTION 'Wasn't trying to talk after all
a$ = UCASE$(b$)

IF lo = 11 THEN
   IF IsItem(a$, 21) AND GetObject(21) = 0 THEN
       SetObject 21, lo
       AddLine 2, GetResource$(lo, "THROWIT"), 1
       VerbThrow = 1: EXIT FUNCTION
   END IF
END IF

END FUNCTION

FUNCTION VerbTurn (b$)

IF IsVerb(b$, "TURN") = 0 THEN EXIT FUNCTION 'Wasn't trying to talk after all
a$ = UCASE$(b$)

IF lo = 6 THEN
    IF IsNoun(a$, "DIAL") OR (IsNoun(a$, "FAN") > 0 AND INSTR(a$, " OFF") > 0) THEN
        IF GetSpecial(35) > 0 THEN
            AddLine 2, GetResource$(lo, "TURNDIAL1"), 1
        ELSE
            IF GetObject(21) <> 0 OR IsItem(a$, 21) = 0 THEN
                AddLine 2, GetResource$(lo, "TURNDIAL2"), 1
            ELSE
                SetSpecial 35, 1
                AddLine 2, GetResource$(lo, "TURNDIAL3"), 1
            END IF
        END IF
        VerbTurn = 1: EXIT FUNCTION
    END IF
END IF

IF lo = 25 THEN
    IF IsNoun(a$, "DIAL") THEN
        IF GetSpecial(28) = 0 THEN
            SetSpecial 28, 1
            AddLine 2, GetResource$(lo, "TURNDIAL1"), 1
        ELSE
            AddLine 2, GetResource$(lo, "TURNDIAL2"), 1
        END IF
        VerbTurn = 1: EXIT FUNCTION
    END IF
END IF

END FUNCTION

FUNCTION VerbUnlock (b$)

IF IsVerb(b$, "UNLOCK") = 0 THEN EXIT FUNCTION 'Wasn't trying to talk after all

a$ = UCASE$(b$)
x = HasDirection(b$)

IF lo = 13 THEN
    IF IsNoun(b$, "DOOR") OR INSTR(b$, " CONF") THEN
        IF GetSpecial(23) <> 0 THEN
            AddLine 2, GetResource$(lo, "NOUNLOCK1"), 1
        ELSE
            IF GetObject(18) <> 0 THEN
                AddLine 2, GetResource$(lo, "NOUNLOCK2"), 1
            ELSE
                SetSpecial 23, 1
                AddLine 2, GetResource$(lo, "UNLOCK"), 1
            END IF
        END IF
        VerbUnlock = 1: EXIT FUNCTION
    END IF
END IF

IF lo = 18 THEN
    IF IsNoun(b$, "DOOR") THEN
        IF INSTR(a$, " LAB") THEN x = 4
        IF x = 0 THEN
            AddLine 2, GetResource$(22, "NOUNLOCK1"), 1
            VerbUnlock = 1: EXIT FUNCTION
        END IF
        IF x <> 3 AND x <> 4 AND x <> 1 THEN
            AddLine 2, GetResource$(22, "NOUNLOCK2"), 1
            VerbUnlock = 1: EXIT FUNCTION
        END IF
        IF x <> 4 THEN
            AddLine 2, GetResource$(22, "NOUNLOCK3"), 1
            VerbUnlock = 1: EXIT FUNCTION
        END IF
        IF GetSpecial(8) = 0 THEN
            AddLine 2, GetResource$(lo, "NOPT1"), 1
            VerbUnlock = 1: EXIT FUNCTION
        END IF
        '** otherwise, we are indeed trying to unlock the East door.
        IF GetSpecial(19) > 0 THEN
            AddLine 2, GetResource$(lo, "NOUNLOCK1"), 1
            VerbUnlock = 1: EXIT FUNCTION
        END IF
        IF GetObject(4) <> 0 THEN
            AddLine 2, GetResource$(22, "NOUNLOCK4"), 1
            VerbUnlock = 1: EXIT FUNCTION
        END IF
        '*** Otherwise, we can unlock this door!
        SetSpecial 19, 1
        AddLine 2, GetResource$(lo, "UNLOCK1"), 1
        VerbUnlock = 1: EXIT FUNCTION
    END IF
END IF

IF lo = 21 THEN
    IF IsNoun(b$, "DOOR") OR INSTR(b$, " EXIT") OR INSTR(b$, " ENTRAN") OR INSTR(b$, " OFFICE") THEN
        IF INSTR(b$, " EXIT") OR INSTR(b$, " ENTRAN") THEN x = 1
        IF INSTR(b$, " OFFICE") THEN x = 3
        IF x = 0 THEN
            AddLine 2, GetResource$(22, "NOUNLOCK1"), 1
        ELSE
            IF x = 3 THEN
                AddLine 2, GetResource$(lo, "NOUNLOCK3"), 1
            ELSE
                IF x = 1 THEN
                    IF GetSpecial(42) <> 0 THEN
                        AddLine 2, GetResource$(lo, "NOUNLOCK1"), 1
                    ELSE
                        IF GetObject(25) <> 0 THEN
                            AddLine 2, GetResource$(lo, "NOUNLOCK2"), 1
                        ELSE
                            SetSpecial 42, 1
                            AddLine 2, GetResource$(lo, "UNLOCK"), 1
                        END IF
                    END IF
                ELSE
                    AddLine 2, GetResource$(22, "NOUNLOCK2"), 1
                END IF
            END IF
        END IF
        VerbUnlock = 1: EXIT FUNCTION
    END IF
END IF


IF lo = 22 THEN
    IF IsNoun(b$, "DOOR") THEN
        IF x = 0 THEN
            AddLine 2, GetResource$(lo, "NOUNLOCK1"), 1
            VerbUnlock = 1: EXIT FUNCTION
        END IF
        IF x <> 3 AND x <> 4 AND x <> 2 THEN
            AddLine 2, GetResource$(lo, "NOUNLOCK2"), 1
            VerbUnlock = 1: EXIT FUNCTION
        END IF
        IF x <> 3 THEN
            AddLine 2, GetResource$(lo, "NOUNLOCK3"), 1
            VerbUnlock = 1: EXIT FUNCTION
        END IF
        '** otherwise, we are indeed trying to unlock the East door.
        IF GetSpecial(4) > 0 THEN
            AddLine 2, GetResource$(lo, "NOUNLOCK5"), 1
            VerbUnlock = 1: EXIT FUNCTION
        END IF
        IF GetObject(4) <> 0 THEN
            AddLine 2, GetResource$(lo, "NOUNLOCK4"), 1
            VerbUnlock = 1: EXIT FUNCTION
        END IF
        '*** Otherwise, we can unlock this door!
        SetSpecial 4, 1
        AddLine 2, GetResource$(lo, "UNLOCK1"), 1
        VerbUnlock = 1: EXIT FUNCTION
    END IF
END IF

END FUNCTION

FUNCTION VerbUnplug (b$)

IF IsVerb(b$, "UNPLUG") = 0 THEN EXIT FUNCTION 'Wasn't trying to talk after all

a$ = UCASE$(b$)
IF lo = 22 THEN
    IF IsNoun(a$, "FRIDGE") THEN
        IF GetSpecial(3) <> 0 THEN
            AddLine 2, GetResource$(lo, "UNPLUG1"), 1
        ELSE
            SetSpecial 3, 1
            AddLine 2, GetResource$(lo, "UNPLUG2"), 1
        END IF
        VerbUnplug = 1: EXIT FUNCTION
    END IF
END IF

VerbUnplug = 0

END FUNCTION

