The deck of cards is stored in a string. Each character represents one card. The value of the character is 48 + suit * 16 + card value.
Here are the routines:
Build the card deck: The deck his held in D$. Uses I and J.
Code: Select all
110 D$="":FORI=1TO4:FORJ=1TO13:D$=D$+CHR$(I*16+48+J):NEXT:NEXT:RETURN
Code: Select all
120 Z=RND(0)*LEN(D$):C$=MID$(D$,Z+1,1):D$=LEFT$(D$,Z)+MID$(D$,Z+2)
Code: Select all
130 Z=ASC(C$):S=Z/16-3:S$=MID$("{shift-s}{shift-z}{shift-a}{shift-x}",S,1):C=ZAND15:C$=MID$("A234567890JQK",C,1):RETURN
Code: Select all
140 Z$=MID$("{black}{red}",S/2+1):PRINT"{black}{shift-u}{shift-asterisk}{shift-i}{down}{left}{left}{left}{shift-minus}"Z$C$"{black}{shift-minus}{down}{left}{left}{left}{shift-minus}"Z$S$"{black}{shift-minus}{down}{left}{left}{left}{shift-j}{shift-asterisk}{shift-k}";:RETURN
Code: Select all
10 GOSUB 110
15 FOR J=1 TO 7
20 FOR I=1 TO 7
30 GOSUB 120
40 GOSUB 140
45 PRINT "{up}{up}{up}";
50 NEXT I
55 PRINT "{down}"
65 NEXT J
80 PRINT
90 END
[/i]