static DWORD fetch_dword(AddressSpace *as, DWORD address) { int dev = (address & DEV_MASK) >> 56; if(!valid_card(address)) { fprintf(stderr, "Warning: attempt to read from %016llX; returning 0xCCCCCCCCCCCCCCCC\n", address); return 0xCCCCCCCCCCCCCCCC; } assert(as->readers); assert(as->readers[dev]); return as->readers[dev](as, address, 3); }
static void store_dword(AddressSpace *as, DWORD address, UDWORD datum) { int dev = (address & DEV_MASK) >> 56; if(!valid_card(address)) { fprintf(stderr, "Warning: attempt to write to %016llX.\n", address); return; } assert(as->writers); assert(as->writers[dev]); as->writers[dev](as, address, datum, 3); }
// ******************************************************************* // FUNCTION: blackjack_hand // // DESCRIPTION: This function will take two cards and tell you what // the blackjack hand total is. // // PARAMETERS: card1 - the first card // card2 - the second card // // OUTPUTS: int - the value of the hand // // CALLS: valid_card // ******************************************************************* int blackjack_hand (char card1, char card2) { bool valid_card (char card); int hand_total; // make the cards uppercase card1 = toupper(card1); card2 = toupper(card2); // check that both inputs are valid if (!valid_card(card1) || !valid_card(card2)) { return -1; } // find the value of card1 if (card1 <= '9' && card1 >= '2') { hand_total = card1 - 48; // subtract 48 from the value of the char to get the int value } else if (card1 == 'T' || card1 == 'J' || card1 == 'Q' || card1 == 'K') { hand_total = 10; } else { // card1 = 'A' hand_total = 11; } // find the value of card2 if (card2 <= '9' && card2 >= '2') { hand_total += card2 - 48; // subtract 48 from the value of the char to get the int value } else if (card2 == 'T' || card2 == 'J' || card2 == 'Q' || card2 == 'K') { hand_total += 10; } else { // card2 = 'A' hand_total += 1; } return hand_total; }