Z80-21 Yet Another "BlackJack"

General games-related topics
Post Reply
User avatar
XavSnap
Posts: 1938
Joined: Sat May 10, 2008 4:23 pm
Location: 'Zx81 France' Fb group.

Re: Z80-21 Yet Another "BlackJack"

Post by XavSnap »

Hi,

Cap0008.jpg
Cap0009.jpg

Code: Select all

   110 DIM C(13*P,4)
   115 FOR R=0 TO (13*P)-1 STEP 13
   118 PRINT "DECK ";(R/13)+1
   120  FOR I=1 TO 4
   130   FOR N=1 TO 13
   #140   PRINT ".";
   150   LET C(N+R,I)=N
   160   NEXT N
   170  NEXT I
   175 NEXT R
   180 LET L=52*P
:ugeek:

490 bytes remain with 6 decks of cards. (dots display removed to speed up the shuffling)
Z8021Beta4_2h.P
(13.54 KiB) Downloaded 50 times
Funny weekend sanello !
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
User avatar
XavSnap
Posts: 1938
Joined: Sat May 10, 2008 4:23 pm
Location: 'Zx81 France' Fb group.

Re: Z80-21 Yet Another "BlackJack"

Post by XavSnap »

Hi Sanello,

This part of code is fast if the array is short.
But at the and of the 6 desks, the RND loops and wast about 10 secound to find a value !

Example: 1 DECK is set, and 5 desks are empty.
Try this test code... it displays the loop to do to retrieve a value.

Code: Select all

   100 LET P=6
   110 DIM C(13*P,4)
   
   120  FOR I=1 TO 4
   130   FOR N=1 TO 13
   150   LET C(N,I)=N
   160   NEXT N
   170  NEXT I
   180 LET R=0

  7000 LET T=INT ((RND*13*P)+1)
  7100 LET S=INT (RND*4+1)
  7200 LET R=R+1
  7500 IF C(T,S)=0 THEN GOTO 7000
  7600 LET C(T,S)=0
  7700 PRINT R;";";
  7800 LET R=0
  7900 GOTO 7000
143 loops = about 10 secounds.
Cap0011.jpg
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
User avatar
XavSnap
Posts: 1938
Joined: Sat May 10, 2008 4:23 pm
Location: 'Zx81 France' Fb group.

Re: Z80-21 Yet Another "BlackJack"

Post by XavSnap »

Hi,

In a perfect world, with a single array DIM C(78)...

Code: Select all

    100 LET P=6
   110 LET CN=0
   112 LET T=13*P
   115 DIM C(T)
   
   120  FOR N=1 TO T
   150  LET C(N)=N
   170  NEXT N

  7000 LET V=INT ((RND*T)+1)
  7010 LET CN=CN+1
  7050 LET R=C(V)
  7100 IF V<>T THEN LET C(V)=C(T)
  7110 LET T=T-1
  7120 PRINT R;";";
  7130 IF T<>0 THEN GOTO 7000
  7200 PRINT "END OF ";CN;" VALUES"
Cap0012.jpg
You don't have to test the empty value, just one test per value.

But, in case of 2 dimensions (multidimensional) array i don't know how to reduce the delay.
:oops:

To host a value <256, prefer a string array (DIM A$(78) for example)... 1 byte per value in the VARS, and read it using CODE A$(x)
The last character will be report to the picked-up value... like the previous example.
For a DIM A$(78,4)... we can't easily move the values.
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
User avatar
sanello
Posts: 100
Joined: Sat Jul 23, 2022 9:26 pm

Re: Z80-21 Yet Another "BlackJack"

Post by sanello »

I've been playing around and I agree. The best way to have multiple decks would be to lose the multi dimensional array and forget about the suits. So I guess instead of giving a choice in one program, you can choose to load one or the other. Or maybe just make it 3 decks since it seems to be the maximum without losing too much performance. Heck, I think it's pretty good the way it is with one deck, though, so maybe just leave it alone?
-sanello
User avatar
XavSnap
Posts: 1938
Joined: Sat May 10, 2008 4:23 pm
Location: 'Zx81 France' Fb group.

Re: Z80-21 Yet Another "BlackJack"

Post by XavSnap »

Hi,

Ok sanello, you are lucky... the weekend is not stated.

I changed the array C(T,S)... and renamed C(T,S)>>CD !

O$(52*CD*2) ... only 624 bytes for 6 deck !
Each card take 2 bytes:
1 BYTE for the value (1 to 13) stay 'T' variable.
1 BYTE for the color.(1 to 4) stay 'S' variable.

C=((card number)*2)-1 point to the first card byte (value)


But, there is the "9820 LET C(G,H)=G".

Your mission this weekend will be to repair the routine:
The famous dealer check...

Code: Select all

  9800 LET A=15
  9810 LET J=0
  9820 LET C(G,H)=G
  9830 LET S=H
  9840 LET T=G
  9850 GOSUB 2000
  9860 PRINT AT 13,0;N$;AT 13,0;Z
  9870 RETURN 
I will write an ASM code to fill the "Decks", and you will able to imagine a 8 decks game...

LISTING:

Code: Select all

     0  REM [HEX:\
00,00,E7,CD,92,0D,CD,F5,\
0B,68,61,CD,D8,09,01,05,\
00,09,EB,2A,0C,40,23,FD,\
36,7C,01,1A,CB,77,CB,B7,\
FD,77,7B,28,0A,13,1A,FD,\
77,7C,FE,01,CA,5B,00,ED,\
4B,7B,40,71,23,CB,76,28,\
01,23,10,F7,13,18,D8,21,\
3D,40,36,20,2A,0C,40,0E,\
16,23,7E,06,1F,F5,23,7E,\
2B,77,23,10,F9,F1,36,88,\
23,0D,20,ED,21,3D,40,35,\
3E,00,BE,20,DF,C9 ]

1 REM [HEX:\
00,81,82,0A,43,04,07,0A,\
06,03,86,0A,06,03,86,4A,\
04,06,03,84,4A,02,81,0A,\
06,86,03,04,83,C0,02,8A,\
4A,03,06,4A,02,05,0A,85,\
0A,05,0A,85,4A,06,06,0A,\
02,C5,02,40,03,85,C0,04,\
4A,02,06,4A,03,84,80,07,\
0A,05,0A,85,0A,87,8A,4A,\
02,06,4A,03,85,0A,86,00,\
87,01,02,84,07,01,0A,06,\
4A,04,05,0A,85,0A,05,0A,\
85,4A,04,06,4A,04,85,4A,\
02,86,01,40,02,43,02,0A,\
81,CA,04,0A,82,8A,81,0A,\
86,8A,06,4A,04,82,CA,02,\
4A,02,81,8A,4A,22,40,42,\
06,C3,1E,86,85,4A,1E,05,\
85,00,2A,33,39,2A,37,00,\
39,26,27,31,2A,00,37,3A,\
31,2A,38,00,87,1D,00,2B,\
34,37,00,1E,0E,1D,00,05,\
85,40,03,2B,34,37,00,1E,\
1D,00,35,26,3E,34,3A,39,\
40,03,87,1E,00,2B,34,37,\
00,1F,0E,1E,00,05,85,40,\
13,87,1F,00,2B,34,37,00,\
22,0E,21,00,05,85,49,1E,\
05,86,43,1E,06,40,26,29,\
2A,28,30,38,00,34,2B,00,\
28,26,37,29,38,0E,40,0D,\
04,40,1E,06,02,04,40,08,\
A6,00,A7,00,A8,00,A9,00,\
AA,00,AB,40,06,87,82,00,\
06,40,02,02,04,40,07,1D,\
00,1E,00,1F,00,20,00,21,\
00,22,40,05,87,C0,02,82,\
02,04,00,06,40,08,03,40,\
0F,02,C0,02,07,00,02,06,\
40,02,35,37,34,2C,37,26,\
72,02,2A,29,00,27,3E,0E,\
00,38,1B,26,33,2A,71,02,\
34,00,87,82,40,41,40,01 ]

     2  REM [HEX:\
CA,05,88,CA,05,88,CA,05,\
88,CA,05,88,CA,05,88,07,\
84,05,40,03,85,88,05,40,\
03,85,88,05,40,03,85,88,\
05,40,03,85,88,05,40,03,\
85,88,05,85,05,40,03,85,\
88,05,40,03,85,88,05,40,\
03,85,88,05,40,03,85,88,\
05,40,03,85,88,05,85,05,\
40,03,85,88,05,40,03,85,\
88,05,40,03,85,88,05,40,\
03,85,88,05,40,03,85,88,\
05,85,05,40,03,85,88,05,\
40,03,85,88,05,40,03,85,\
88,05,40,03,85,88,05,40,\
03,85,88,05,85,05,40,03,\
85,88,05,40,03,85,88,05,\
40,03,85,88,05,40,03,85,\
88,05,40,03,85,88,05,85,\
C9,05,88,C9,05,88,C9,05,\
88,C9,05,88,C9,05,88,05,\
85,CA,04,C8,1A,82,81,40,\
03,80,C9,16,B5,B1,A6,BE,\
AA,B7,CA,03,80,CA,1C,3C,\
26,71,02,2A,39,8D,40,05,\
85,40,16,27,2A,39,8D,40,\
05,85,40,13,C9,03,80,C9,\
1C,40,03,80,CA,14,A8,B7,\
B4,BA,B5,AE,AA,B7,43,04,\
40,1A,07,84,8F,C8,03,8F,\
00,C8,05,00,C8,05,00,C8,\
05,00,C8,05,00,05,85,C8,\
05,00,C8,05,00,C8,05,00,\
C8,05,00,C8,05,00,05,85,\
C8,05,00,C8,05,00,C8,05,\
00,C8,05,00,C8,05,00,05,\
85,C8,05,00,C8,05,00,C8,\
05,00,C8,05,00,C8,05,00,\
05,85,C8,05,00,C8,05,00,\
C8,05,00,C8,05,00,C8,05,\
00,05,85,C8,05,00,C8,05,\
00,C8,05,00,C8,05,00,C8,\
05,00,05,85,8F,C8,03,8F,\
00,C8,05,00,C8,05,00,C8,\
05,00,C8,05,00,82,81,40,\
40,40,01 ]

     3  REM [HEX:\
C8,08,40,02,0E,16,40,02,\
87,C9,03,04,40,02,16,0E,\
00,C8,0F,40,03,0E,40,03,\
85,1B,0B,1B,05,40,03,0E,\
40,02,C8,0D,0E,16,00,16,\
0E,40,02,81,80,0A,11,00,\
07,04,40,02,0E,16,00,16,\
C8,0C,0E,40,03,0E,00,85,\
88,02,8A,16,06,00,85,40,\
02,0E,40,03,C8,0B,00,0E,\
40,03,0E,00,81,88,04,88,\
89,18,87,00,05,00,0E,40,\
03,0E,C8,09,40,02,0E,40,\
03,0E,85,88,87,05,88,32,\
00,85,05,02,04,0E,40,03,\
0E,C8,09,00,09,0E,40,03,\
87,89,8A,81,05,88,3B,00,\
85,80,04,86,40,02,5A,02,\
0E,C8,08,00,49,02,0E,16,\
00,87,03,C4,02,80,10,88,\
0E,00,11,80,84,03,86,00,\
D8,03,00,C8,06,C9,1B,C8,\
03,40,FF,40,E0,40,01 ]

     5 LET SC=16516
     6 LET SD=16577
     7 LET M$="     "
     8 GOSUB 9100
     9 RAND 
    10 DIM P(5)
    20 DIM D(5)
    30 DIM A$(4,3)
    40 LET A$(1)="CLB"
    50 LET A$(2)="SPD"
    60 LET A$(3)="DMD"
    70 LET A$(4)="HRT"
    71 LET B$="¼¸¸¸¯"
    72 LET C$="ª®®®¬"
    73 LET D$="winner«"
    74 LET F$="loser«"
    75 LET G$="draw«"
    76 LET I$="push«"
    77 LET J$="µµµµµ³"
    78 LET K$="º   °"
    79 LET L$="´´´´´³"
    81 LET N$="   "
    85 LET W=1000
    88 LET CD=0
    90 CLS 
    91 IF W<2 THEN GOTO 9900
    92 IF W>9999 THEN GOTO 9970
   100 PRINT AT 0,0;"SHUFFLING",,
   
#   110 DIM C(13,4)
#   120 FOR I=1 TO 4
#   130 FOR N=1 TO 13
#   140 PRINT ".";
#   150 LET C(N,I)=N
#   160 NEXT N
#   170 NEXT I

# 13 VALUES*4 COLORS*P

   110 DIM O$(2*52*P)
   112 LET L=1
   115 FOR R=1 TO P
# C(1)=COLOR *52*P= "C$=CHR$ I"
# C(2)=VALUE *52*P= "C$=CHR$ N"
   117 PRINT "DESK ";R
   120  FOR N=1 TO 13 
   130   FOR I=1 TO 4
   140   LET O$(L TO)=CHR$ N+CHR$ I
   155   LET L=L+2
   160   NEXT I
   170  NEXT N
   175 NEXT R



   180 LET L=52*P
   190 RAND USR SD
   191 PRINT USR SC,VAL "3"
   194 IF W<1 THEN GOTO 9900
   195 IF W>9999 THEN GOTO 9970
   196 LET Y1=0
   197 LET Y2=Y1
   198 LET P1=0
   199 LET P2=P1
   200 PRINT AT 10,0;"WALLET:$";M$;AT 10,8;W
   204 DIM P(5)
   208 DIM D(5)
   210 PRINT AT 11,0;"BET ?";M$;M$
   220 INPUT B
   221 IF B/2=INT (B/2) THEN GOTO 224
   222 PRINT AT 11,0;"EVEN BETS ONLY"
   223 GOTO 270
   225 LET V=0
   226 LET E=V
   227 LET S=V
   228 LET T=V
   229 LET U=V
   230 LET B=INT B
   240 IF B<=W AND B<501 AND B>0 THEN GOTO 315
   250 IF B>W THEN GOTO 300
   260 PRINT AT 11,0;"max500min1"
   270 GOSUB 1300
   290 GOTO 210
   300 PRINT AT 11,0;"$LOW FUNDS$"
   310 GOTO 270
   320 RAND USR SD
   340 PRINT USR SC,VAL "2"
   350 PRINT AT 10,7;M$;AT 10,7;W-B;AT 11,7;M$;AT 11,7;B
   360 LET W=W-B
   364 LET Q=0
   368 LET B1=Q
   370 LET B2=Q
   375 LET A=Q
   380 LET J=Q
   390 GOSUB 7000
   400 LET F=CD
   410 LET E$=A$(S)
   420 IF CD>9 THEN LET P(1)=10
   430 IF CD>1 AND CD<=9 THEN LET P(1)=CD
   440 IF CD=1 THEN LET P(1)=11
   455 GOSUB 9096
   460 GOSUB 2000
   462 IF U AND Y=1 THEN LET Y=11
   464 IF U AND Y=11 THEN LET P(1)=11
   465 PRINT AT 8,0;N$;AT 8,0;Y;
   470 LET J=6
   480 GOSUB 7000
   490 IF NOT U THEN LET M=CD
   500 IF CD>9 THEN LET P(2)=10
   510 IF CD>1 AND CD<=9 THEN LET P(2)=CD
   520 IF CD=1 THEN LET P(2)=11
   535 GOSUB 9096
   540 IF Y>21 THEN LET P(1)=1
   541 GOSUB 9096
   542 GOSUB 2000
   545 PRINT AT 8,0;N$;AT 8,0;Y;
   547 IF U>0 THEN GOTO 715
   550 LET A=15
   560 LET J=0
   570 GOSUB 7000
   575 LET H=S
   576 LET G=T
   580 IF CD>9 THEN LET D(1)=10
   590 IF CD>1 AND CD<=9 THEN LET D(1)=CD
   591 IF CD=1 THEN LET D(1)=11
   595 LET CD=0
   610 GOSUB 5000
   620 LET J=6
   630 GOSUB 7000
   640 IF CD>9 THEN LET D(2)=10
   650 IF CD>1 AND CD<=9 THEN LET D(2)=CD
   660 IF CD=1 THEN LET D(2)=11
   665 GOSUB 9092
   670 IF Z>21 AND D(1)=11 THEN LET D(1)=1
   685 GOSUB 9092
   690 GOSUB 2000
   692 PRINT AT 13,0;N$;AT 13,0;D(2)
   697 IF U=1 THEN GOTO 715
   700 IF F=M THEN GOSUB 8000
   705 IF NOT U THEN GOSUB 9000
   710 IF U=1 THEN GOTO 460
   715 IF NOT U THEN LET BC=B
   716 IF U=1 THEN LET BC=B1
   717 IF U=2 THEN LET BC=B2

   718 IF W>=B+BC THEN PRINT AT 10,13;"HIT,STAY OR DOUBLE?";TAB 14;M$;"H/S/D";M$;N$
   719 IF W<B+BC THEN PRINT AT 10,13;" HIT OR STAY? H/S"
   720 GOSUB 8300
   730 PRINT AT 10,13;M$;M$;M$;N$;" ";TAB 13;M$;M$;M$;N$;" "
   740 IF H$="S" THEN GOTO 3000
   750 IF H$="H" THEN GOTO 770
   755 IF H$="D" THEN GOTO 765
   760 GOTO 718
   765 IF W>=B+BC THEN GOTO 770
   767 GOTO 715
   770 LET A=0
   771 LET J=12
   772 IF H$<>"D" THEN GOTO 787
   774 LET W=W-BC
   776 LET B=B+BC
   780 IF U=2 THEN LET B2=B2+B2
   785 IF U=1 THEN LET B1=B1+B1
   787 PRINT AT 10,7;M$;AT 10,7;W;TAB 7;B
   789 IF U<>0 THEN PRINT AT 10,13;"BET1 $";B1;" BET2 $";B2
   790 GOSUB 7000
   800 IF CD>9 THEN LET P(3)=10
   810 IF CD>1 AND CD<=9 THEN LET P(3)=CD
   820 IF CD=1 THEN LET P(3)=11
   825 GOSUB 9096
   830 FOR I=1 TO 3
   840 IF Y>21 AND P(I)=11 THEN LET P(I)=1
   850 GOSUB 9096
   855 NEXT I
   860 GOSUB 2000
   870 IF Y>21 THEN GOTO 3000
   880 PRINT AT 8,0;N$;AT 8,0;Y;TAB 4;"´´´´´´´´´"
   885 IF H$="D" THEN GOTO 3000
   890 PRINT AT 10,14;"HIT OR STAY? H/S"
   900 GOSUB 8300
   910 PRINT AT 10,14;M$;M$;M$;" "
   920 IF H$="S" THEN GOTO 3000
   930 IF H$="H" THEN GOTO 950
   940 GOTO 890
   950 LET J=18
   960 GOSUB 7000
   970 IF CD>9 THEN LET P(4)=10
   980 IF CD>1 AND CD<=9 THEN LET P(4)=CD
   990 IF CD=1 THEN LET P(4)=11
   995 GOSUB 9096
  1000 FOR I=1 TO 4
  1010 IF Y>21 AND P(I)=11 THEN LET P(I)=1
  1020 GOSUB 9096
  1030 NEXT I
  1040 GOSUB 2000
  1050 IF Y>21 THEN GOTO 3000
  1060 PRINT AT 8,0;N$;AT 8,0;Y;
  1070 PRINT AT 10,14;"HIT OR STAY? H/S"
  1080 GOSUB 8300
  1090 PRINT AT 10,14;M$;M$;M$;" "
  1100 IF H$="S" THEN GOTO 3000
  1110 IF H$="H" THEN GOTO 1130
  1120 GOTO 1070
  1130 LET J=24
  1140 GOSUB 7000
  1150 IF CD>9 THEN LET P(5)=10
  1160 IF CD<=9 THEN LET P(5)=CD
  1170 FOR I=1 TO 4
  1180 IF P(I)=11 THEN LET P(I)=1
  1190 NEXT I
  1195 GOSUB 9096
  1200 GOSUB 2000
  1201 IF Y>21 AND P(5)=11 THEN LET P(5)=1
  1202 GOSUB 9096
  1205 IF U=1 THEN LET P1=P(5)
  1207 IF U=2 THEN LET P2=P(5)
  1210 IF Y>21 THEN GOTO 3000
  1220 PRINT AT 8,0;N$;AT 8,0;Y;
  1230 GOTO 3000
  1300 FOR I=1 TO 50
  1310 NEXT I
  1320 RETURN 
  2000 GOSUB 5000+(CD*100)
  2030 LET CD=0
  2040 RETURN 

  3000 GOSUB 9096
  3006 PRINT AT 8,0;Y;TAB 4;"’bust’" AND Y>21;"´´´´´´´´´"
  3008 IF U=1 THEN GOSUB 8160
  3010 IF U=2 THEN GOSUB 8260
  3012 GOSUB 9800

  3014 IF Z>16 THEN GOTO 4510
  3015 LET J=12
  3016 IF Y>21 THEN GOTO 4515
  3017 IF Y1>21 AND Y2>21 THEN GOTO 4800
  3020 GOSUB 7000
  3030 IF CD>9 THEN LET D(3)=10
  3040 IF CD<=9 THEN LET D(3)=CD
  3050 IF CD=1 THEN LET D(3)=11
  3055 GOSUB 9092
  3060 FOR I=1 TO 3
  3070 IF Z>21 AND D(I)=11 THEN LET D(I)=1
  3080 GOSUB 9092
  3085 NEXT I
  3090 GOSUB 2000
  3095 PRINT AT 13,0;N$;AT 13,0;Z
  3100 IF Z>21 THEN GOTO 4500
  3110 IF Z>16 THEN GOTO 4510
  3120 LET J=18
  3130 GOSUB 7000
  3140 IF CD>9 THEN LET D(4)=10
  3150 IF CD<=9 THEN LET D(4)=CD
  3160 IF CD=1 THEN LET D(4)=11
  3165 GOSUB 9092
  3170 FOR I=1 TO 4
  3180 IF Z>21 AND D(I)=11 THEN LET D(I)=1
  3190 GOSUB 9092
  3200 NEXT I
  3210 GOSUB 2000
  3220 PRINT AT 13,0;N$;AT 13,0;Z
  3230 IF Z>21 THEN GOTO 4500
  3240 IF Z>16 THEN GOTO 4510
  3250 LET J=24
  3260 GOSUB 7000
  3270 IF CD>9 THEN LET D(5)=10
  3280 IF CD<=9 THEN LET D(5)=CD
  3290 IF CD=1 THEN LET D(5)=11
  3295 GOSUB 9092
  3300 FOR I=1 TO 5
  3310 IF Z>21 AND D(I)=11 THEN LET D(I)=1
  3320 GOSUB 9092
  3330 NEXT I
  3350 GOSUB 2000
  3360 PRINT AT 13,0;N$;AT 13,0;Z
  3370 IF Z>21 THEN GOTO 4500
  3380 GOTO 4510
  4500 PRINT AT 13,0;Z;TAB 4;"’bust’"
  4510 GOSUB 9092
  4515 LET K=0
  4516 IF Y1>0 THEN GOTO 4800
  4530 IF Y>Z AND Y<22 THEN LET K=1
  4540 IF Z>21 AND Y<22 THEN LET K=1
  4550 IF Z=Y AND Y<22 THEN LET K=3
  4554 IF Z<22 AND Y<22 AND P(5)>0 THEN LET K=1
  4556 IF Y=21 AND Z<>21 THEN LET K=2
  4560 IF K=1 THEN LET W=W+B+B
  4565 IF K=2 THEN LET W=INT (W+B+(B*(O/X)))
  4570 IF K=3 THEN LET W=W+B
  4580 IF K=1 OR K=2 THEN PRINT AT 3,0;"««";D$;D$;D$;D$;"««"
  4590 IF K=3 THEN PRINT AT 3,0;"«";G$;I$;G$;I$;G$;I$;"«"
  4600 IF NOT K THEN PRINT AT 3,0;"««";F$;F$;F$;F$;F$
  4610 GOSUB 1300
  4630 GOTO 4910
  4800 LET K1=0
  4801 LET K2=0
  4804 IF Y1>Z AND Y1<22 THEN LET K1=1
  4805 IF Y2>Z AND Y2<22 THEN LET K2=1
  4810 IF Z>21 AND Y1<22 THEN LET K1=1
  4815 IF Z>21 AND Y2<22 THEN LET K2=1
  4820 IF Z=Y1 AND Y1<22 THEN LET K1=3
  4825 IF Z=Y2 AND Y2<22 THEN LET K2=3
  4830 IF Z<22 AND Y1<22 AND P1>0 THEN LET K1=1
  4835 IF Z<22 AND Y2<22 AND P2>0 THEN LET K2=1
  4837 IF Y1=21 AND Z<>21 THEN LET K1=2
  4838 IF Y2=21 AND Z<>21 THEN LET K2=2
  4840 IF K1=1 THEN LET W=W+B1+B1
  4845 IF K2=1 THEN LET W=W+B2+B2
  4847 IF K1=2 THEN LET W=INT (W+(B1*(O/X)))
  4848 IF K2=2 THEN LET W=INT (W+(B2*(O/X)))
  4850 IF K1=3 THEN LET W=W+B1
  4855 IF K2=3 THEN LET W=W+B2
  4860 IF K1=1 OR K1=2 THEN PRINT AT 3,0;"«««hand˜«";D$;D$;D$;"««"
  4865 IF K2=1 OR K2=2 THEN PRINT AT 5,0;"«««hand™«";D$;D$;D$;"««"
  4870 IF K1=3 THEN PRINT AT 3,0;"«hand˜«";I$;G$;I$;G$;I$
  4875 IF K2=3 THEN PRINT AT 3,0;"«hand™«";I$;G$;I$;G$;I$
  4880 IF NOT K1 THEN PRINT AT 3,0;"«hand˜«";F$;F$;F$;F$;"«"
  4885 IF NOT K2 THEN PRINT AT 5,0;"«hand™«";F$;F$;F$;F$;"«"
  4890 GOSUB 1300

#  4910 IF L>16 THEN GOTO 190
#  4920 GOTO 90

  4910 GOTO 90+(100 AND L>16)

  5000 PRINT AT A,J;"«¯¯¯¯";TAB J;"ª±±±¯";TAB J;"ª±±±¯";TAB J;"ª±±±¯";TAB J;"ª±±±¯";TAB J;"ª±±±¯";TAB J;"ªªªª«"
  5040 RETURN 
  5100 PRINT AT A,J;B$;TAB J;"º²¸¹°";TAB J;"ºº °°";TAB J;"º¼¸¯°";TAB J;"ºº °°";TAB J;"º";A$(S);"°";TAB J;C$
  5170 RETURN 
  5200 PRINT AT A,J;B$;TAB J;"º 2 °";TAB J;K$;TAB J;"º 2 °";TAB J;K$;TAB J;"º";A$(S);"°";TAB J;C$
  5270 RETURN 
  5300 PRINT AT A,J;B$;TAB J;"º 3 °";TAB J;"º 3 °";TAB J;"º 3 °";TAB J;K$;TAB J;"º";A$(S);"°";TAB J;C$
  5370 RETURN 
  5400 PRINT AT A,J;B$;TAB J;"º4 4°";TAB J;K$;TAB J;"º4 4°";TAB J;K$;TAB J;"º";A$(S);"°";TAB J;C$
  5470 RETURN 
  5500 PRINT AT A,J;B$;TAB J;"º5 5°";TAB J;"º 5 °";TAB J;"º5 5°";TAB J;K$;TAB J;"º";A$(S);"°";TAB J;C$
  5570 RETURN 
  5600 PRINT AT A,J;B$;TAB J;"º6 6°";TAB J;"º6 6°";TAB J;"º6 6°";TAB J;K$;TAB J;"º";A$(S);"°";TAB J;C$
  5670 RETURN 
  5700 PRINT AT A,J;B$;TAB J;"º7 7°";TAB J;"º 7 °";TAB J;"º7 7°";TAB J;"º7 7°";TAB J;"º";A$(S);"°";TAB J;C$
  5770 RETURN 
  5800 PRINT AT A,J;B$;TAB J;"º8 8°";TAB J;"º8 8°";TAB J;"º8 8°";TAB J;"º8 8°";TAB J;"º";A$(S);"°";TAB J;C$
  5870 RETURN 
  5900 PRINT AT A,J;B$;TAB J;"º9 9°";TAB J;"º9 9°";TAB J;"º999°";TAB J;"º9 9°";TAB J;"º";A$(S);"°";TAB J;C$
  5970 RETURN 
  6000 PRINT AT A,J;B$;TAB J;"ºTEN°";TAB J;"º ˜ °";TAB J;"º — °";TAB J;"ºTEN°";TAB J;"º";A$(S);"°";TAB J;C$
  6070 RETURN 
  6100 PRINT AT A,J;B$;TAB J;"º·¯¸°";TAB J;"º ° °";TAB J;"º ° °";TAB J;"º±» °";TAB J;"º";A$(S);"°";TAB J;C$
  6170 RETURN 
  6200 PRINT AT A,J;B$;TAB J;"º²¸¹°";TAB J;"ºº °°";TAB J;"ºº²°°";TAB J;"º·®±°";TAB J;"º";A$(S);"°";TAB J;C$
  6270 RETURN 
  6300 PRINT AT A,J;B$;TAB J;"ºº »°";TAB J;"ºª» °";TAB J;"º¼± °";TAB J;"ºº ±°";TAB J;"º";A$(S);"°";TAB J;C$
  6370 RETURN 

  
#  7000 LET T=INT ((RND*13*P)+1)
#  7100 LET S=INT (RND*4+1)
#  7500 IF C(T,S)=0 THEN GOTO 7000


# ALL 'C(T,S)'='CD'='T'='card value'
# 

  7000 LET C=((INT(RND*L)+1)*2)-1
  7100 LET T=CODE O$(C)
  7200 LET S=CODE O$(C+1)
  7400 IF C=(L*2)-1 THEN GOTO 7500
  7410 LET O$(C)=O$((L*2)-1)
  7420 LET O$(C+1)=O$(L*2)
  7510 LET CD=T
  7540 LET L=L-1
  7550 PRINT AT 14,10;"CARDS LEFT:";L;" "
  7600 RETURN 


  8000 IF W<B+B AND NOT U THEN RETURN 
  8005 IF U=2 THEN RETURN 
  8006 GOSUB 9000
  8010 PRINT AT 7,8;"splitŠ Y OR N"
  8012 GOSUB 8300
  8014 LET Q$=H$
  8015 IF Q$="Y" THEN GOTO 8050
  8020 IF Q$="N" THEN RETURN 
  8030 GOTO 8010
  8040 RETURN 

  8050 LET U=1
  8056 LET A=0
  8058 PRINT AT 7,8;"³³³³³³³³³³³³³"
  8060 PRINT AT 5,0;"hand˜"
  8070 GOSUB 8400
  8080 LET B1=B
  8090 LET B2=B
  8100 PRINT AT 11,13;"BET1 $";B1;" BET2 $";B2
  8110 LET W=W-B1
  8120 LET B=B+B
  8130 PRINT AT 10,7;M$;AT 10,7;W;AT 11,7;M$;AT 11,7;B
  8142 IF F=1 THEN LET P(1)=11
  8150 RETURN 

  8160 LET Y1=Y
  8162 GOSUB 1300
  8166 PRINT AT 8,0;N$
  8170 LET U=2
  8180 FOR I=2 TO 5
  8190 LET P(I)=0
  8200 NEXT I
  8210 LET CD=M
  8215 PRINT AT 5,0;"hand™"
  8220 LET A=0
  8230 LET J=0
  8235 GOSUB 8400
  8240 PRINT AT 10,14;"hand˜ SUM:";Y1
  8250 GOTO 470

  8260 LET Y2=Y
  8262 GOSUB 1300
  8270 PRINT AT 10,14;"hand™ SUM:";Y2
  8280 RETURN 

  8300 IF INKEY$<>"" THEN GOTO 8300
  8310 IF INKEY$="" THEN GOTO 8310
  8320 LET H$=INKEY$
  8330 RETURN 
  8400 PRINT AT 0,6;J$;J$;J$;J$
  8410 FOR I=1 TO 5
  8420 PRINT TAB 6;K$;"³";K$;"³";K$;"³";K$
  8430 NEXT I
  8440 PRINT TAB 6;L$;L$;L$;L$
  8450 RETURN 
  9000 IF Y=21 AND Z=21 THEN GOSUB 9800
  9001 IF Y<>21 AND D(2)=11 AND W>=B/2 THEN GOTO 9019
  9002 IF Y=21 AND Z<>21 THEN LET K=2
  9003 IF Z=21 AND Y<>21 THEN LET K=0
  9004 IF Z<>21 AND Y<>21 THEN RETURN 
  9005 GOSUB 9800
  9006 GOTO 4560

  9019 PRINT AT 7,8;"insuranceŠ Y/N"
  9020 GOSUB 8300
  9022 LET Q$=H$
  9030 PRINT AT 7,8;"³³³³³³³³³³³³³³"

 # 9030 IF Q$="Y" THEN GOTO 9070
 # 9040 IF Q$="N" THEN GOTO 9081
 # 9060 GOTO 9010

 9040 GOTO 9010+(60 AND Q$="Y")+(71 AND Q$="N")

  9070 IF Z=21 THEN LET W=W+(B/2)
  9075 IF Z<>21 THEN LET W=W-(B/2)
  9076 PRINT AT 10,7;M$;AT 10,7;W
  9078 IF Z=21 THEN PRINT AT 13,0;Z;TAB 4;"ins–«won"
  9080 IF Z<>21 THEN PRINT AT 13,0;Z;TAB 4;"ins–«lost"
  9081 IF Z=21 THEN GOSUB 9800
  9082 IF Z=21 THEN GOTO 4515
  9090 GOTO 9002
  9092 LET Z=D(1)+D(2)+D(3)+D(4)+D(5)
  9094 RETURN 
  9096 LET Y=P(1)+P(2)+P(3)+P(4)+P(5)
  9098 RETURN 
  9100 PRINT USR SC,VAL "1"
  9200 LET P=1
  9300 GOSUB 8300
  9400 LET Q$=H$
  9410 IF Q$>"0" AND Q$<"4" THEN GOTO 9430
  9415 IF Q$>"9" AND Q$<"G" THEN GOSUB 9460

  9420 GOTO 9300
  9430 LET O=(2 AND Q$="1")+(3 AND Q$="2")+(6 AND Q$="3")
  9440 LET X=(1 AND Q$="1")+(2 AND Q$="2")+(5 AND Q$="3")
  9450 RETURN 
  9460 PRINT AT 20,12;M$;M$
  9470 LET P=CODE Q$-37
  9480 PRINT AT 20,10+(P*2);"¸"
  9490 RETURN
  9500 SAVE "Z8021"
  9510 RUN 

  9800 LET A=15
  9810 LET J=0
  9820 LET C(G,H)=G
  9830 LET S=H
  9840 LET T=G
  9850 GOSUB 2000
  9860 PRINT AT 13,0;N$;AT 13,0;Z
  9870 RETURN 

  9900 PRINT AT 10,0;"WALLET EMPTY",
  9910 PRINT ,,,"PLAY AGAIN? Y/N"
  9920 GOSUB 8300

#  9930 IF H$="Y" THEN RUN
#  9950 IF H$="N" THEN GOTO 9999
#  9960 GOTO 9920

9930 RUN (9999 AND NOT H$="Y")

  9970 PRINT AT 10,0;"YOU BEAT THE HOUSE WINNING";TAB 12;"$";W
  9990 GOTO 9910
  9999 PRINT ,,"THANKS FOR PLAYING"
Bugged release to fixe: (1500 bytes remain with a 6 decks of card)
Editing cursor bug removed.
Z8021_tofixe.P
(13.45 KiB) Downloaded 50 times
Last edited by XavSnap on Fri Aug 05, 2022 6:36 pm, edited 1 time in total.
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
User avatar
XavSnap
Posts: 1938
Joined: Sat May 10, 2008 4:23 pm
Location: 'Zx81 France' Fb group.

Re: Z80-21 Yet Another "BlackJack"

Post by XavSnap »

Hi,
The ASM SHUFFLING... i had to add a delay to see the screen...

Code: Select all

;------- TASM ASM mnemonics. -------
; Compile this file using:
; Set TASMOPTS = -b
; tasm -80 ThisCode.tas MyBinary.BIN
;-----------------------------------
; Zx81 Program name: VB81 XuR [Z8021_ASM.P] :
; REM   line   name: D=16616/16654 : H=40E8/410E

#define ORG  .org       ; TASM cross-assembler definitions
#define equ  .equ
;-----------------------------------

;------- ROM and RAM Symbols -------
RAM_DEST equ $4012
RAM_SPARE1 equ $4021

ORG $40E8 ; [@16616/@h40E8]

	LD HL,(RAM_DEST) ; GET DEST
Lb40EB:
	LD DE,$0100 
Lb40EE:
	LD B,$04 
Lb40F0:
	LD (HL),D 
	INC HL 
	INC E 
	LD (HL),E 
	INC HL 
	DJNZ Lb40F0 ; [$40F0:16624]
	INC D 
	LD A,D 
	CP $0E ; [14-":"]
	JR Z, Lb4101 ; [$4101:16641]
	LD E,$00 
	JR Lb40EE ; [$40EE:16622]
Lb4101:
	DEC (IY+33) 
	LD A,(RAM_SPARE1) ; GET UNUSED-8
	CP $00 ; [0]
	JR NZ, Lb40EB ; [$40EB:16619]
	LD BC,$0001 
	RET ; ==========================
.end

Release to sanello my favorite BASIC debugger: ( 2/9820 error)
Z8021_ASM.P
(13.44 KiB) Downloaded 52 times
P=8 working... 8 Decks of cards, the shuffling delay isn't a problem now.
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
User avatar
XavSnap
Posts: 1938
Joined: Sat May 10, 2008 4:23 pm
Location: 'Zx81 France' Fb group.

Re: Z80-21 Yet Another "BlackJack"

Post by XavSnap »

Hi Sanello,

Code: Select all

  9800 LET A=15
  9810 LET J=0
  9820 LET C(G,H)=G
  9830 LET S=H
  9840 LET T=G
  9850 GOSUB 2000
  9860 PRINT AT 13,0;N$;AT 13,0;Z
  9870 RETURN 
Will be

Code: Select all

  9800 LET A=15
  9810 LET J=0
  9820 LET CD=G
  9830 LET S=H
  9840 LET T=G
  9850 GOSUB 2000
  9860 PRINT AT 13,0;N$;AT 13,0;Z
  9870 RETURN 
Why do you set a burned card ?
9820 LET C(G,H)=G
C(G,H)= COLOR

The hidden card can be reuse after a deal ?
You have both values ... G=value and H=color
And S/T point to the card...

This card was a mistake to me...
Z8021_ASM_test2.P
(13.44 KiB) Downloaded 45 times

It's 10:00 PM , i will let sanello play to his game (weekend).
Have Fun.

Sorry for the various 'P' files, working or not. I put them to show and following the update process time line.
In the last message, this program will be an example for future BASIC programers !
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
Moggy
Posts: 3200
Joined: Wed Jun 18, 2008 2:00 pm

Re: Z80-21 Yet Another "BlackJack"

Post by Moggy »

Very nice Sanello/Xav. :D

I'm liking this as much as Z-ZEE
User avatar
XavSnap
Posts: 1938
Joined: Sat May 10, 2008 4:23 pm
Location: 'Zx81 France' Fb group.

Re: Z80-21 Yet Another "BlackJack"

Post by XavSnap »

Yes Thanks sanello.

It was a pretty good game, it will be a wonderful game !
:geek:

The program was coded in ZX81's early BASIC current 1982-83...
All technic from 1986 are present in this game.
More memory for more graphics...

Can't stop to find tips to speed up my one code:

Code: Select all

#  7410 LET O$(C)=O$((L*2)-1)
#  7420 LET O$(C+1)=O$(L*2)

  7410 LET O$(C TO C+1)=O$((L*2)-1)+O$(L*2)
Last edited by XavSnap on Fri Aug 05, 2022 10:43 pm, edited 1 time in total.
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
Moggy
Posts: 3200
Joined: Wed Jun 18, 2008 2:00 pm

Re: Z80-21 Yet Another "BlackJack"

Post by Moggy »

Not too fast Xav, remember my zeddy runs BASIC at double speed! :lol:
Post Reply