std::string URI::getAuthority() const { std::string auth; if (!_userInfo.empty()) { auth.append(_userInfo); auth += '@'; } auth.append(_host); if (_port && !isWellKnownPort()) { auth += ':'; NumberFormatter::append(auth, _port); } return auth; }
int romMapperGameReaderCreate(int cartSlot, int slot, int sslot) { DeviceCallbacks callbacks = { destroy, NULL, saveState, loadState }; RomMapperGameReader* rm; int i; rm = malloc(sizeof(RomMapperGameReader)); rm->deviceHandle = deviceManagerRegister(ROM_GAMEREADER, &callbacks, rm); rm->slot = slot; rm->sslot = sslot; rm->cartSlot = cartSlot; rm->gameReader = gameReaderCreate(cartSlot); // read initial buffer if (!gameReaderRead(rm->gameReader, 0x4000, rm->romData + 0x4000, 0x4000)) { memset(rm->romData, 0xff, 0x10000); } if (!gameReaderRead(rm->gameReader, 0x8000, rm->romData + 0x8000, 0x4000)) { memset(rm->romData, 0xff, 0x10000); } if (rm->gameReader != NULL) { ioPortRegisterUnused(cartSlot, readIo, writeIo, rm); slotRegister(slot, sslot, 0, 8, read, read, write, destroy, rm); for (i = 0; i < 8; i++) { slotMapPage(rm->slot, rm->sslot, i, NULL, 0, 0); } } for(i = 0; i <= 0xffff; i++) { // mark scc as known port if (isWellKnownPort(i)) { rm->mapperStatus[i]= MAPPER_ADDRESS_PORT; } else { rm->mapperStatus[i]= MAPPER_ADDRESS_UNKNOWN; } } rm->mapperList = NULL; return 1; }
std::string URI::getAuthority() const { std::string auth; if (!_userInfo.empty()) { auth.append(_userInfo); auth += '@'; } if (_host.find(':') != std::string::npos) { auth += '['; auth += _host; auth += ']'; } else auth.append(_host); if (_port && !isWellKnownPort()) { auth += ':'; NumberFormatter::append(auth, _port); } return auth; }
static void write(RomMapperGameReader* rm, UInt16 address, UInt8 value) { int i; UInt8 newBuffer[0x10000]; UInt16 start = 0xffff; UInt16 length = 0; MapperList* mapperList; // address has been classified as a port, do nothing if (rm->mapperStatus[address] == MAPPER_ADDRESS_PORT) { return; } // this value was already written to address and nothing happend, do nothing again. if (rm->mapperStatus[address] == value) { return; } // address has been classified as a mapper, restore cache if (rm->mapperStatus[address] == MAPPER_ADDRESS_MAPPER) { mapperList = rm->mapperList; while (1) { if (mapperList->address == address) { length = mapperList->length; start = mapperList->start; if (mapperList->value == value ) { memcpy(rm->romData+start, mapperList->data, length); return; } } if (mapperList->next == NULL) { break; } else { mapperList = mapperList->next; } } // new block mapperList->next = malloc(sizeof(mapperList)); mapperList = mapperList->next; // init entry mapperList->address = address; mapperList->start = start; mapperList->value = value; mapperList->length = length; mapperList->data = malloc(length); mapperList->next = NULL; // read data gameReaderWrite(rm->gameReader, address, &value, 1); gameReaderRead(rm->gameReader, start, mapperList->data, length); // copy to romdata memcpy(rm->romData+start, mapperList->data, length); return; } // address has an unknown or read-once status, examine. gameReaderWrite(rm->gameReader, address, &value, 1); gameReaderRead(rm->gameReader, 0x4000, newBuffer + 0x4000, 0x4000); gameReaderRead(rm->gameReader, 0x8000, newBuffer + 0x8000, 0x4000); // search for changed area for(i=0x4000; i<0xc000; i++) { if (i == address || isWellKnownPort(i)) { continue; // skip write address! } if (rm->romData[i] != newBuffer[i]) { if (start == 0xffff) { start = i; } length = i-start+1; } } // check for port (second write with a different value, but still no change) if (!length) { if (rm->mapperStatus[address] != value && rm->mapperStatus[address] <= 0xff ) { rm->mapperStatus[address] = MAPPER_ADDRESS_PORT; } else { rm->mapperStatus[address] = value; } return; } // round length for(i=0;i<0x8000;i+=0x1000) { if (length<i) { length = i; break; } } // we found a mapper! rm->mapperStatus[address] = MAPPER_ADDRESS_MAPPER; mapperList = rm->mapperList; if (mapperList == NULL) { mapperList = malloc(sizeof(mapperList)); rm->mapperList = mapperList; } else { while (mapperList->next != NULL) { mapperList = mapperList->next; } mapperList->next = malloc(sizeof(mapperList)); mapperList = mapperList->next; } mapperList->next = NULL; mapperList->start = start; mapperList->length = length; mapperList->address = address; mapperList->value = value; mapperList->data = (UInt8*)malloc(length); memcpy(mapperList->data,newBuffer+start,length); memcpy(rm->romData+start,newBuffer+start,length); return; }