void StandbyState::Update() { if(ENGINE->GetProcessManager()->GetNumQueueProcesses()) { return; } if(GetCurrentError()) { return; } if(!global_quit) { #ifdef SOAK_BUILD add_cdeposit(2000); #endif THE_BUTTONS->StandbyButtons(); THE_GAME->UpdateDigits(); if(GetSwitchStatus(REFILL_KEY)) { THE_GAME->QuitToMainMenu(); return; } if(ENGINE->GetSystemTimer().GetRunningTime() > m_standbyTimer) { if((GetTerminalFormat() > 1) && (!GetDynamicDoNotQuitGame(MODEL_NUMBER))) THE_GAME->QuitToMainMenu(); } if(GetCredits()+GetBankDeposit() >= MINIMUM_BET) { ENGINE->StateTransition("DealStart"); } if(THE_BUTTONS->OSButtonPressed("HoldInfoButton")) { ENGINE->StateTransition("Help"); return; } else if(THE_BUTTONS->ButtonPressed("Menu")) { THE_GAME->QuitToMainMenu(); } if((GetCredits()+GetBankDeposit() > 0)) { if(THE_BUTTONS->ButtonPressed("Collect")) { ENGINE->GetProcessManager()->AddProcessToQueue(new CollectProcess); } } } }
CurrencyValue CCurrencyBlock::GetCredits (const CString &sCurrency) // GetCredits // // Returns the number of credits available in the given currency { ASSERT(!sCurrency.IsBlank()); CEconomyType *pEcon = g_pUniverse->FindEconomyType(sCurrency); if (pEcon == NULL) return 0; return GetCredits(pEcon->GetUNID()); }
/* here is where the test starts */ A_STATUS DoMboxHWTest(AR6K_DEVICE *pDev) { int i; A_STATUS status; int credits = 0; A_UINT8 params[4]; int numBufs; int bufferSize; A_UINT16 temp; AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, (" DoMboxHWTest START - \n")); do { /* get the addresses for all 4 mailboxes */ status = HIFConfigureDevice(pDev->HIFDevice, HIF_DEVICE_GET_MBOX_ADDR, g_MailboxAddrs, sizeof(g_MailboxAddrs)); if (status != A_OK) { A_ASSERT(FALSE); break; } /* get the block sizes */ status = HIFConfigureDevice(pDev->HIFDevice, HIF_DEVICE_GET_MBOX_BLOCK_SIZE, g_BlockSizes, sizeof(g_BlockSizes)); if (status != A_OK) { A_ASSERT(FALSE); break; } /* note, the HIF layer usually reports mbox 0 to have a block size of * 1, but our test wants to run in block-mode for all mailboxes, so we treat all mailboxes * the same. */ g_BlockSizes[0] = g_BlockSizes[1]; AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, ("Block Size to use: %d \n",g_BlockSizes[0])); if (g_BlockSizes[1] > BUFFER_BLOCK_PAD) { AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, ("%d Block size is too large for buffer pad %d\n", g_BlockSizes[1], BUFFER_BLOCK_PAD)); break; } AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, ("Waiting for target.... \n")); /* the target lets us know it is ready by giving us 1 credit on * mailbox 0 */ status = GetCredits(pDev, 0, &credits); if (status != A_OK) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Failed to wait for target ready \n")); break; } AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, ("Target is ready ...\n")); /* read the first 4 scratch registers */ status = HIFReadWrite(pDev->HIFDevice, SCRATCH_ADDRESS, params, 4, HIF_RD_SYNC_BYTE_INC, NULL); if (status != A_OK) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Failed to wait get parameters \n")); break; } numBufs = params[0]; bufferSize = (int)(((A_UINT16)params[2] << 8) | (A_UINT16)params[1]); AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, ("Target parameters: bufs per mailbox:%d, buffer size:%d bytes (total space: %d, minimum required space (w/padding): %d) \n", numBufs, bufferSize, (numBufs * bufferSize), TOTAL_BYTES)); if ((numBufs * bufferSize) < TOTAL_BYTES) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Not Enough buffer space to run test! need:%d, got:%d \n", TOTAL_BYTES, (numBufs*bufferSize))); status = A_ERROR; break; } temp = GetEndMarker(); status = HIFReadWrite(pDev->HIFDevice, SCRATCH_ADDRESS + 4, (A_UINT8 *)&temp, 2, HIF_WR_SYNC_BYTE_INC, NULL); if (status != A_OK) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Failed to write end marker \n")); break; } AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, ("End Marker: 0x%X \n",temp)); temp = (A_UINT16)g_BlockSizes[1]; /* convert to a mask */ temp = temp - 1; status = HIFReadWrite(pDev->HIFDevice, SCRATCH_ADDRESS + 6, (A_UINT8 *)&temp, 2, HIF_WR_SYNC_BYTE_INC, NULL); if (status != A_OK) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Failed to write block mask \n")); break; } AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, ("Set Block Mask: 0x%X \n",temp)); /* execute the test on each mailbox */ for (i = 0; i < AR6K_MAILBOXES; i++) { status = DoOneMboxHWTest(pDev, i); if (status != A_OK) { break; } } } while (FALSE); if (status == A_OK) { AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, (" DoMboxHWTest DONE - SUCCESS! - \n")); } else { AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, (" DoMboxHWTest DONE - FAILED! - \n")); } /* don't let HTC_Start continue, the target is actually not running any HTC code */ return A_ERROR; }
/* wait for the buffers to come back */ static A_STATUS RecvBuffers(AR6K_DEVICE *pDev, int mbox) { A_STATUS status = A_OK; A_UINT32 request = HIF_RD_SYNC_BLOCK_INC; BUFFER_PROC_LIST recvList[BUFFER_PROC_LIST_DEPTH]; int curBuffer; int credits; int i; int totalBytes = 0; int paddedLength; int totalwPadding = 0; AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, ("Waiting for buffers on mailbox : %d \n",mbox)); /* zero the buffers */ InitBuffers(FILL_ZERO); /* assemble the order in which we should receive */ AssembleBufferList(recvList); curBuffer = 0; while (curBuffer < BUFFER_PROC_LIST_DEPTH) { /* get number of buffers that have been completed, this blocks * until we get at least 1 credit or it times out */ status = GetCredits(pDev, mbox, &credits); if (status != A_OK) { break; } AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, ("Got %d messages on mailbox : %d \n",credits, mbox)); /* get all the buffers that are sitting on the queue */ for (i = 0; i < credits; i++) { A_ASSERT(curBuffer < BUFFER_PROC_LIST_DEPTH); /* recv the current buffer synchronously, the buffers should come back in * order... with padding applied by the target */ paddedLength = (recvList[curBuffer].length + (g_BlockSizes[mbox] - 1)) & (~(g_BlockSizes[mbox] - 1)); status = HIFReadWrite(pDev->HIFDevice, g_MailboxAddrs[mbox], recvList[curBuffer].pBuffer, paddedLength, request, NULL); if (status != A_OK) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Failed to read %d bytes on mailbox:%d : address:0x%X \n", recvList[curBuffer].length, mbox, g_MailboxAddrs[mbox])); break; } totalwPadding += paddedLength; totalBytes += recvList[curBuffer].length; curBuffer++; } if (status != A_OK) { break; } /* go back and get some more */ credits = 0; } if (totalBytes != TEST_BYTES) { A_ASSERT(FALSE); } else { AR_DEBUG_PRINTF(ATH_PRINT_OUT_ZONE, ("Got all buffers on mbox:%d total recv :%d (w/Padding : %d) \n", mbox, totalBytes, totalwPadding)); } return status; }