- iPhysicalAddress += (uint16_t)(iPort * iPos);
- strLog.Format("checking physical address %4x", iPhysicalAddress);
- AddLog(CEC_LOG_DEBUG, strLog);
- if (PhysicalAddressInUse(iPhysicalAddress))
- {
- strLog.Format("physical address %4x is in use", iPhysicalAddress);
- AddLog(CEC_LOG_DEBUG, strLog);
- iPos = (iPos == 1) ? 0 : iPos / 0x10;
- }
- else
- {
- strLog.Format("physical address %4x is free", iPhysicalAddress);
- AddLog(CEC_LOG_DEBUG, strLog);
- SetPhysicalAddress(iPhysicalAddress);
- bReturn = true;
- }
+ SetPhysicalAddress((uint16_t)iPort * 0x1000);
+ bReturn = false;
+ }
+ else
+ {
+ if (iPhysicalAddress == 0)
+ iPhysicalAddress += 0x1000 * iPort;
+ else if (iPhysicalAddress % 0x1000 == 0)
+ iPhysicalAddress += 0x100 * iPort;
+ else if (iPhysicalAddress % 0x100 == 0)
+ iPhysicalAddress += 0x10 * iPort;
+ else if (iPhysicalAddress % 0x10 == 0)
+ iPhysicalAddress += iPort;
+
+ SetPhysicalAddress(iPhysicalAddress);
+ bReturn = true;