![]() |
![]() |
![]() |
![]() |
|
|||||||||||||||||||||||||||||||
DrawingDrawing is guided by the player's choice of what cards to hold. Since there are five cards, and each of them may either be held or not held, the choice can be expressed as a 5-bit binary number called Held. Assume a “1” bit means that a card will be held. Then if bit 0 is set in Held, that means the player wants to hold card 0, etc. Since Held is 5 bits, there are 32 possible configurations. These range from 00000 (no cards held) to 11111 (all cards held). |
One Chip Video Poker Project |
How Drawing Actually WorksGiven Held and a 10-card hand, it's easy to construct the new hand. Note that since card 0 is drawn leftmost, and bit 0 of binary numbers are drawn rightmost, Held appears to be backwards (rightmost bit corresponds to leftmost card). The process involves a handy assembly trick I call Mask Rolling, used to test bits one by one in a byte. The PIC is able to test individual bits in a byte using the BTFSC / BTFSS instructions, but they require that you specify which bit you're testing at compile time – you can test bit 0, or bit 1, or whatever, but you can't test bit X. Instead, you have to test by bitwise masking. That is, if you want to test bit X in byte B, do a bitwise AND of B and a “mask” which is a byte with only the bit of interest set. If the result is zero, that bit is clear in B; if nonzero, the bit is set in B.
|
|||||||||||||||||||||||||||||
|
Here's an example. Say the 10-card hand consists of ABCDEPQRST. The pat hand, then, is ABCDE, and the draw set is PQRST. The Hand Pointer starts out pointing at A, and the Draw Pointer at P. Assume the player wants to hold cards 0 and 3 (A and D).
So the final hand is A P Q D R. There isn't a separate unit test for drawing; it's covered in the scoring test on the next page. |
|||||||||||||||||||||||||||||||
|
Page Top
|