Cards
The cards use a simple system of splitting the value into two halves, the first
four bits signify the card value - which, for the ease of evaluating the hands,
starts from 0 representing "Two".
Then, in order (as you'd expect), the cards are:
Diamonds |
Hearts |
Spades |
Clubs |
Byte |
Card |
Byte |
Card |
Byte |
Card |
Byte |
Card |
0 |
Two |
16 |
Two |
32 |
Two |
48 |
Two |
1 |
Three |
17 |
Three |
33 |
Three |
49 |
Three |
2 |
Four |
18 |
Four |
34 |
Four |
50 |
Four |
3 |
Five |
19 |
Five |
35 |
Five |
51 |
Five |
4 |
Six |
20 |
Six |
36 |
Six |
52 |
Six |
5 |
Seven |
21 |
Seven |
37 |
Seven |
53 |
Seven |
6 |
Eight |
22 |
Eight |
38 |
Eight |
54 |
Eight |
7 |
Nine |
23 |
Nine |
39 |
Nine |
55 |
Nine |
8 |
Ten |
24 |
Ten |
40 |
Ten |
56 |
Ten |
9 |
Jack |
25 |
Jack |
41 |
Jack |
57 |
Jack |
10 |
Queen |
26 |
Queen |
42 |
Queen |
58 |
Queen |
11 |
King |
27 |
King |
43 |
King |
59 |
King |
12 |
Ace |
28 |
Ace |
44 |
Ace |
60 |
Ace |
The upper four bits, when shifted four positions to the right, represent the
suits. Obviously, they don't have to be shifted, just this is how the game
evaluates them, so that's what we'll do here.
The suits are: 0: Diamonds, 1: Hearts, 2: Spades and 3: Clubs.
Card Graphics
Here are some examples of cards and their values:
Byte |
Bits |
Breakdown |
Result |
Lower |
Upper |
Card |
Suit |
Byte |
Bits |
Byte |
Bits |
6 |
00000110 |
6 |
0110 |
0 |
0000 |
Eight |
Diamonds |
12 |
00001100 |
12 |
1100 |
0 |
0000 |
Ace |
Diamonds |
25 |
00011001 |
9 |
1001 |
1 |
0001 |
Jack |
Hearts |
26 |
00011010 |
10 |
1010 |
1 |
0001 |
Queen |
Hearts |
39 |
00100111 |
7 |
0111 |
2 |
0010 |
Nine |
Spades |
43 |
00101011 |
11 |
1011 |
2 |
0010 |
King |
Spades |
52 |
00110100 |
4 |
0100 |
3 |
0011 |
Six |
Clubs |
To follow the mechanism in the game, start from
PrintHand which cycles through
all five cards in a hand and prints them to the screen via
CheckCardType.
* The picture card routine is not shown here as it complicates things, check
the disassembly for further details.
Let's take an example and follow it all the way through: 37
The AND
turns it into 5, so this card is a "Seven".
So, our card 37 will end up writing
Graphics_CardSeven to *
PointerCardUDGData (which will be used later).
This references the number part of the card (without any suit applied yet).
With 37 after shifting the bits, we end up with 2 - so the suit is
Spades. And after the "Find" loop,
HL will point to
Graphics_SpadesSuitData which is
then copied into
Buffer_CardData so it becomes the "upper part" of the font data and
can be referenced by the UDG data.
Next, we set the UDG font pointer and discover the colour of the card to be
printed.
|
58350 |
LD HL,58207 |
|
58353 |
LD (23606),HL |
|
58356 |
LD A,19 |
|
58358 |
RST 16 |
|
58359 |
LD A,1 |
|
58361 |
RST 16 |
|
58362 |
LD A,16 |
|
58364 |
RST 16 |
|
58365 |
LD A,0 |
|
58367 |
RST 16 |
|
58368 |
LD A,(58722) |
|
58371 |
CP 2 |
|
58373 |
JR NC,PrintCard |
|
58375 |
LD A,16 |
|
58377 |
RST 16 |
|
58378 |
LD A,2 |
|
58380 |
RST 16 |
Our suit is 2 so the colour will be BLACK.
Now we have all the components, we know the card UDG data and the suit UDG data
has been copied into the upper range of it. We also know the colour too, so all
that's left to do is to print it on the screen using
PrintCard.
The cards are printed using the standard Spectrum printing routine, and so the
data is stored as a series of references:
66 |
67 |
67 |
67 |
67 |
68 |
80 |
107 |
95 |
95 |
107 |
81 |
105 |
95 |
97 |
98 |
95 |
106 |
65 |
95 |
99 |
100 |
95 |
69 |
65 |
101 |
95 |
95 |
101 |
69 |
For ease of explaining this, if the data just referenced ASCII - then the print
would output the following letter graphics:
B |
C |
C |
C |
C |
D |
P |
k |
_ |
_ |
k |
Q |
i |
_ |
a |
b |
_ |
j |
A |
_ |
c |
d |
_ |
E |
A |
e |
_ |
_ |
e |
E |
How the code works, is that we write 58207 to
CHARS
and this is where the "magic" happens! Rather than reference the graphics for
each letter in ROM - the print routine references the game UDGs instead.
So the data we have links through to these address (click to see):
And produces the following output:
The blank spaces are due to the cards being stored "suit-less" (at least on
game load anyway). The print routine copies in the suit UDGs when printing
every card (regardless of the previous card suit). So the final result looks
like this:
Girls
To save on space, the girls are created with one initial image, and then the
other "frames" are single sections which are overlaid on top of them.
This means that often, an image is an amalgamation of several images all
printed on top of each other.