// CASIO BASIC and C.BASIC compatible // For fx-9860GII SD /** BSD 2-Clause License Copyright (c) 2022, LdBeth All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ '#CBINT // use integer processing to speed up Locate 1,1,"BLACKJACK DX" // Deluxe version, with 28->Dim List 1 // surrender, double down, insurance, 7 charlie feature. 100->B:10->A // B: Budget A: Bet Locate 1,2,"DEALER MUST STAND" Locate 1,3,"ON 17 AND MUST" // Standard Blackjack rule Locate 1,4,"DRAW TO 16" Lbl 1 // Main loop Locate 1,6,"Press EXE" While Getkey // Must make sure no key is been pressed WhileEnd Do LpWhile Getkey<>31 B>=1500=>Goto 9 // Winning condition For 2->N To 6 Locate 1,N," " // Clear display Next Locate 1,7,"Budget:" Locate 8,7," " Locate 8,7,B Locate 13,7,"Bet:" Do A>B=>B-A Locate 1,6,"Bet?^v MENU DEL" Locate 17,7," " Locate 17,7,A While Getkey WhileEnd Do:Getkey LpWhile Not Ans Ans->Z Z=44=>Goto 9 // DEL to exit game Z=28=>(A+10)<=B=>A+10->A Z=37=>(A-10)>0=>A-10->A LpWhile Z<>48 // EXE to confirm For 1->N To 28 RanInt#(1,13)->Z // This is slow on CASIO BASIC Z>10=>10->Z // Assuming we are drawing from an infinite card pool Z->List 1[N] Next // J: Current card index K: is Double Down I: rate 2->J:0->K:1->I:0->R // R: Insurance Lbl 2 // Loop for calculate player points 0->C:0->T // C: Has Aces T: Total points For 1->N To J List 1[N]->Z Z+T->T Z=1=>1->C Next C=>(10+T)<=21=>10+T->T Locate 1,2,"Player:" Locate 8,2,T // This is always two digits For 1->N To J List 1[N]->Z If Z<10 Then Locate 10+N,2,Z Else Locate 10+N,2,"10" // one char IfEnd:Next Locate 1,5,"Dealer:" Locate 8,5,List 1[8] // Dealer's first card If T>21 Then Locate 1,4,"BUST" I-2->I:Goto 8 // - is negative sign IfEnd If T=21 Then Locate 1,4,"BLACKJACK!" B+Int(3A%2)->B // Blackjack pay 1.5 Goto 1 IfEnd If J=7 Then Locate 1,4,"*SEVEN CARDS*" // Auto winning B+5000->B:Goto 1 IfEnd K=>Goto 3// If double downed, go to reveal dealer's cards If J=2 Then If List 1[8]=1 // Insurance Then Locate 1,3,"Insurance?" Locate 1,6,"1:YES Othr:NO " While Getkey WhileEnd Do:Getkey LpWhile Not Ans If Ans=72 Then Locate 12,3,"Y" 1->R IfEnd IfEnd If List 1[8]+List 1[9]=21 Then Locate 1,4,"DEALER BLJK" Not R=>B-A->B Goto 1 // Lose nothing if insured Else R=>B-A->B Locate 8,7," " Locate 8,7,B IfEnd Locate 1,6,"1:SURR 2:D.DN " While Getkey WhileEnd Do:Getkey LpWhile Not Ans Ans->Z If Z=72 Then B-Int A%2->B // Surrender loses half bets Goto 1 IfEnd If Z=62 Then Locate 1,3,"DOUBLE DOWN" 2A->A:Locate 17,7,A // Refresh bet J+2->J:8->K // Draw two cards Goto 2 IfEnd IfEnd Locate 1,6,"1:HIT Othr:HOLD" While Getkey WhileEnd Do:Getkey LpWhile Not Ans If Ans=72 Then J+1->J Goto 2 IfEnd 8->K // Reuse K for dealer card index Lbl 3 0->C:0->D For 7->N To K List 1[N]->Z Z+D->D Z=1=>1->C Next C=1=>(D+10)<=21=>D+10->D If D<=16 Then K+1->K Goto 3 IfEnd Locate 8,5,D If D=T:Then Locate 1,4,"PUSH" I-1->I Else D>21=>Locate 1,4,"DEALER BUST" DLocate 1,4,"YOU WIN" If D<=21 And D>T Then Locate 1,4,"YOU LOSE" I-2->I IfEnd IfEnd Lbl 8 B+IA->B B>0=>Goto 1 Lbl 9 If B>=1500 Then Locate 10,4,"CHIK DINNER" "WINNING" B/ // Show B Else Locate 12,4,"GAME OVER" IfEnd