DECLARE SUB Card.Frame ()
DECLARE SUB OpenHeading ()
DECLARE SUB CashDisp (Players.Cash)
DECLARE SUB Clear.Line ()
RANDOMIZE TIMER

CLS

'***** Prints opening heading *****
CALL OpenHeading
LOCATE 4, 1
PRINT "Hello!  Welcome to blackjack!  Get ready to play for some serious fun cuz you'll"
PRINT "                be laughing really hard at this stupid program"
PRINT

'***** Determines how much money the player starts out with *****
INPUT "Are you a High Roller or a wussy boy(H/W)? -->", Player.Type$

Player.Type$ = UCASE$(Player.Type$)

IF Player.Type$ = "H" THEN
   Players.Cash = 10000
ELSEIF Player.Type$ = "W" THEN
   Players.Cash = 100
ELSE
   Players.Cash = 100
END IF

'***** Main Program *****
DO UNTIL Play.Again$ = "N" OR Play.Again$ = "B"
  

   '***** Displays cash in bottom screen corner *****
   
   CALL CashDisp(Players.Cash)
  
   '***** Initializes Variables *****
   Winner$ = ""
   Comp.Stop.Go$ = ""
   Card.Limit$ = ""
   LoseByBust$ = ""
   Ok.To.Proceed.On.Bet$ = ""
  

   '***** Asks user for waiger *****
   LOCATE 1, 1
   INPUT "Please enter your waiger  -->", Waiger
  

   '***** Makes sure waiger is a valid number *****
   DO UNTIL Ok.To.Proceed.On.Bet$ = "Y"
      IF Waiger > Players.Cash THEN
         INPUT "You overbet! Please enter your waiger -->", Waiger
      ELSEIF Waiger = 0 THEN
         INPUT "You must bet!  Please enter your waiger -->", Waiger
      ELSEIF Waiger < Players.Cash THEN
         Ok.To.Proceed.On.Bet$ = "Y"
      ELSEIF Waiger = Players.Cash THEN
         Ok.To.Proceed.On.Bet$ = "Y"
      END IF
   LOOP
  

   '***** Randomly Chooses Player's first two cards, and totals them *****
   LET Card.1 = INT(RND * 10) + 1
   LET Card.2 = INT(RND * 10) + 1
   LET Player.Total = Card.2 + Card.1


   '***** Clears screen and re-prints players score *****
   CALL CashDisp(Players.Cash)
   LOCATE 1, 1
   CALL Card.Frame

   '***** Prints values of first two cards on the screen *****
   LOCATE 3, 4
   PRINT Card.1
   LOCATE 3, 16
   PRINT Card.2
   

   '***** Initializes cursor position for placing additional cards *****
   Cursor.X.Pos = 15


   '***** Asks player if they want to hit or stay *****
   LOCATE 7, 1
   INPUT "Hit or stay (H/S)? ->", Hit.Stay$
   Hit.Stay$ = UCASE$(Hit.Stay$)
  

   '***** Initializes loop and 5 card limit *****
   Card.Count = 2


   '***** Draws additional cards and checks to see if they go over 21 *****
   DO UNTIL Hit.Stay$ = "S"
      LET Card.X = INT(RND * 10) + 1
     
      Card.Count = Card.Count + 1
      IF Card.Count = 6 THEN
         Card.Limit$ = "Y"
      END IF
     
      IF Card.X = 1 THEN
         DO UNTIL Proceed.With.Draw$ = "Y"
            INPUT "Do you want your ace to be a 1 or 11? (1,11) -->", Ace
            IF Ace = 1 THEN
               LET Card.X = 1
               Proceed.With.Draw$ = "Y"
            ELSEIF Ace = 11 THEN
               LET Card.X = 11
               Proceed.With.Draw$ = "Y"
            END IF
         LOOP
         LOCATE 8, 1
         CALL Clear.Line
      END IF
      LET Player.Total = Player.Total + Card.X
      Cursor.X.Pos = Cursor.X.Pos + 14
      LOCATE 3, Cursor.X.Pos
      PRINT Card.X
      IF Player.Total > 21 THEN
         LET LoseByBust$ = "Bust"
         Hit.Stay$ = "S"
      ELSEIF Player.Total = 21 THEN
         LET Winner$ = "PlayerBlackjack"
         Hit.Stay$ = "S"
      END IF
      
      IF Card.Limit$ = "Y" THEN
         Hit.Stay$ = "S"
      ELSEIF Hit.Stay$ = "S" THEN
      ELSE
         LOCATE 7, 1
         CALL Clear.Line
         LOCATE 7, 1
         INPUT "Hit or stay (H/S)? ->", Hit.Stay$
         Hit.Stay$ = UCASE$(Hit.Stay$)
      END IF
   LOOP


   '***** Draws comps first two cards and totals their values*****
   LET Comp.Card.1 = INT(RND * 10) + 1
   LET Comp.Card.2 = INT(RND * 10) + 1
   LET Comp.Total = Comp.Card.2 + Comp.Card.1


   '***** Draws frame for comp's cards *****
   LOCATE 9, 1
   CALL Card.Frame
  
   '***** prints values of comp's first two cards *****
   LOCATE 11, 4
   PRINT Comp.Card.1
   LOCATE 11, 16
   PRINT Comp.Card.2
  
   Comp.Cursor.X = 15
   Comp.Card.Count = 2
    
   '***** Decides whether the comp should draw more cards, and then *****
   '*****        checks to see if comp busts, holds, or wins        *****   
   DO UNTIL Comp.Stop.Go$ = "Stop"
      Comp.Card.Count = Comp.Card.Count + 1
      IF Comp.Card.Count = 6 THEN
         Comp.Stop.Go$ = "Stop"
      END IF
    
      IF Comp.Total > 21 THEN
         LET Winner$ = "Player"
         LET Comp.Stop.Go$ = "Stop"
      ELSEIF (Comp.Total >= 18 AND Comp.Total <= 21) OR (Comp.Total > Player.Total) THEN
         Comp.Stop.Go$ = "Stop"
      ELSEIF Comp.Total < 18 AND Comp.Total > 0 THEN
         Comp.Card.3 = INT(RND * 10) + 1
         Comp.Total = Comp.Total + Comp.Card.3
         Comp.Cursor.X = Comp.Cursor.X + 14
         LOCATE 11, Comp.Cursor.X
         PRINT Comp.Card.3
      END IF
   LOOP
   
   PRINT
  
   '***** Checks to see who won, or if winner is already defined *****
   '*****                    skips the loop                      *****
   IF Winner$ = "PlayerBlackjack" THEN
   ELSEIF Winner$ = "Comp" THEN
   ELSEIF Winner$ = "Player" THEN
   ELSEIF Player.Total > Comp.Total THEN
      Winner$ = "Player"
   ELSEIF Player.Total < Comp.Total THEN
      Winner$ = "Comp"
   ELSEIF Player.Total = Comp.Total THEN
      Winner$ = "Push"
   END IF
  

   '***** Tells player whether or not they won, then calculates *****
   '*****                   the player's bank                   *****
   LOCATE 15, 1
   IF LoseByBust$ = "Bust" THEN
      PRINT "Bust!  You lose!"
      Players.Cash = Players.Cash - Waiger
   ELSEIF Winner$ = "Player" THEN
      PRINT "Congrats!  You win!"
      Players.Cash = Players.Cash + Waiger
   ELSEIF Winner$ = "PlayerBlackjack" THEN
      PRINT "You win via BlackJack!"
      Players.Cash = Players.Cash + (Waiger * 2)
   ELSEIF Winner$ = "Comp" THEN
      PRINT "You lose to the comp"
      Players.Cash = Players.Cash - Waiger
   ELSEIF Winner$ = "Push" THEN
      PRINT "This hand was pushed.  You tied!"
   ELSEIF Winner$ = "Bust" THEN
      PRINT "Bust!  You lose!"
      Players.Cash = Players.Cash - Waiger
   END IF

   '***** Pauses so the user can see the last hand
   INPUT "Please hit enter", Enter$

  
   '***** Asks user if they'd like to play again *****
   
   '***** Checks to see if player is out of cash or if they wanna quit *****
   IF Players.Cash = 0 THEN
      CLS
      CALL OpenHeading
      LOCATE 5, 1
      PRINT "Sorry, you're out of cash!  You lose!  You suck!  Get a dayjob!"
      Play.Again$ = "B"
   ELSE
      LOCATE 16, 1
      INPUT "Play again (Y/N)? ->", Play.Again$
      Play.Again$ = UCASE$(Play.Again$)
   END IF
  
  
   IF Play.Again$ = "N" THEN
      CLS
      CALL CashDisp(Players.Cash)
      LOCATE 1, 1
      CALL OpenHeading
      LOCATE 5, 35
      PRINT "Goodbye!"
   END IF
LOOP

END

SUB Card.Frame
   PRINT " *******     *******      *******       *******      *******        *******"
   PRINT " *     *     *     *      *     *       *     *      *     *        *     *"
   PRINT " *     *     *     *      *     *       *     *      *     *        *     *"
   PRINT " *     *     *     *      *     *       *     *      *     *        *     *"
   PRINT " *******     *******      *******       *******      *******        *******"
END SUB

SUB CashDisp (Players.Cash)
   CLS
   Cash.Output$ = "Your cash - $"
   LOCATE 24, 1
   PRINT Cash.Output$; Players.Cash
END SUB

SUB Clear.Line
   Clear$ = "                                                           "
   PRINT Clear$
END SUB

SUB OpenHeading
PRINT "                    B L A C K J A C K   V E R S I O N  2.1"
PRINT "                          B Y   J O E   R I E G E R"
PRINT "--------------------------------------------------------------------------------"
END SUB

    Source: geocities.com/timessquare/realm/4985

               ( geocities.com/timessquare/realm)                   ( geocities.com/timessquare)