PERROR CGame::inputRead( int key ) { PERROR error = errorSuccess; if (key == DOWN_KEY) { if (m_inputReadRegion > 0) { m_inputReadRegion--; } } if (key == UP_KEY) { if (m_inputRegion[m_inputReadRegion+1].mask != 0) { m_inputReadRegion++; } } { const INPUT_REGION *region = &m_inputRegion[m_inputReadRegion]; if (key == SELECT_KEY) { UINT8 recData = 0; errorCustom->description = "OK:"; // // Check if we need to perform a bank switch for this region. // and do that now for all the testing to be done upon it. // if (region->bankSwitch != NO_BANK_SWITCH) { error = region->bankSwitch( (void *) this ); } error = m_cpu->memoryRead( region->address, &recData ); STRING_UINT8_HEX(errorCustom->description, (recData & region->mask) ); } else { STRING_IO_SUMMARY(errorCustom, region->location, region->mask, region->description); } } if (SUCCESS(error)) { error = errorCustom; } return error; }
PERROR CGame::romRead( int key ) { PERROR error = errorSuccess; if (key == SELECT_KEY) { const ROM_REGION *region = &m_romRegion[m_RomReadRegion]; UINT8 data[4] = {0}; errorCustom->description = "OK:"; // // Check if we need to perform a bank switch for this region. // and do that now for all the testing to be done upon it. // if (region->bankSwitch != NO_BANK_SWITCH) { error = region->bankSwitch( (void *) this ); } // // Read the first 4 bytes, maximum. // if (SUCCESS(error)) { for (UINT16 address = 0 ; address < ARRAYSIZE(data) ; address++) { error = m_cpu->memoryRead( (address + region->start), &data[address] ); if (FAILED(error)) { break; } STRING_UINT8_HEX(errorCustom->description, data[address]); error = errorCustom; } } } else { error = onRomKeyMove(key); } return error; }
// // Write & read the first few data bytes and print them into the error string. // PERROR CRamCheck::writeReadData( const RAM_REGION *ramRegion ) { PERROR error = errorSuccess; UINT16 expData4[4] = {0x1111, 0x2222, 0x4444, 0x8888}; UINT16 expData1[4] = {0x5555, 0xAAAA, 0x5555, 0xAAAA}; UINT16 *expData = (UINT16*) NULL;; UINT16 recData[4] = {0}; UINT8 dataBusWidth = m_cpu->dataBusWidth(ramRegion->start); UINT8 dataAccessWidth = m_cpu->dataAccessWidth(ramRegion->start); // // This is more complicated than this simple test // as it needs the bit shift done to be correct. // if ((ramRegion->mask < 4) || (dataAccessWidth > 1)) { expData = expData1; } else { expData = expData4; } errorCustom->description = "OK:"; // // Check if we need to perform a bank switch for this region. // and do that now for all the testing to be done upon it. // if (ramRegion->bankSwitch != NO_BANK_SWITCH) { error = ramRegion->bankSwitch( m_bankSwitchContext ); } // // Write the first 4 bytes, maximum. // if (SUCCESS(error)) { for (UINT32 index = 0 ; index < (4 / dataAccessWidth) ; index++) { error = m_cpu->memoryWrite( (index * (dataBusWidth * ramRegion->step)) + ramRegion->start, expData[index] ); if (FAILED(error)) { break; } } } // // Read the first 4 bytes, maximum. // if (SUCCESS(error)) { if (dataAccessWidth == 1) { for (UINT32 index = 0 ; index < 4 ; index++) { error = m_cpu->memoryRead( (index * (dataBusWidth * ramRegion->step)) + ramRegion->start, &recData[index] ); if (FAILED(error)) { break; } STRING_UINT8_HEX(errorCustom->description, (recData[index] & ramRegion->mask) ); error = errorCustom; } } else if (dataAccessWidth == 2) { for (UINT32 index = 0 ; index < 2 ; index++) { error = m_cpu->memoryRead( (index * (dataBusWidth * ramRegion->step)) + ramRegion->start, &recData[index] ); if (FAILED(error)) { break; } STRING_UINT16_HEX(errorCustom->description, (recData[index] & ramRegion->mask) ); error = errorCustom; } } else { error = errorNotImplemented; } } return error; }
PERROR CGame::ramWriteRead( int key ) { PERROR error = errorSuccess; if (key == SELECT_KEY) { const RAM_REGION *region = &m_ramRegion[m_RamWriteReadRegion]; UINT8 expData4[4] = {0x11, 0x22, 0x44, 0x88}; UINT8 expData1[4] = {0x55, 0xAA, 0x55, 0xAA}; UINT8 *expData = (UINT8*) NULL;; UINT8 recData[4] = {0}; // // This is more complicated than this simple test // as it needs the bit shift done to be correct. // if (region->mask < 4) { expData = expData1; } else { expData = expData4; } errorCustom->description = "OK:"; // // Check if we need to perform a bank switch for this region. // and do that now for all the testing to be done upon it. // if (region->bankSwitch != NO_BANK_SWITCH) { error = region->bankSwitch( (void *) this ); } // // Write the first 4 bytes, maximum. // if (SUCCESS(error)) { for (UINT16 address = 0 ; address < ARRAYSIZE(recData) ; address++) { error = m_cpu->memoryWrite( (address + region->start), expData[address] ); if (FAILED(error)) { break; } } } if (SUCCESS(error)) { // // Read the first 4 bytes, maximum. // for (UINT16 address = 0 ; address < ARRAYSIZE(recData) ; address++) { error = m_cpu->memoryRead( (address + region->start), &recData[address] ); if (FAILED(error)) { break; } STRING_UINT8_HEX(errorCustom->description, (recData[address] & region->mask) ); error = errorCustom; } } } else { error = onRamKeyMove(key); } return error; }