private boolean hasMappedAddressIfNeeded() {
		if (blockType != MemoryBlockType.BIT_MAPPED && blockType != MemoryBlockType.BYTE_MAPPED) {
			return true;
		}
		if (baseAddr == null) {
			message = "Please enter a valid mapped region Source Address";
			return false;
		}

		if (blockType == MemoryBlockType.BYTE_MAPPED) {
			if (schemeDestByteCount <= 0 || schemeDestByteCount > Byte.MAX_VALUE ||
				schemeSrcByteCount <= 0 || schemeSrcByteCount > Byte.MAX_VALUE) {
				message = "Mapping Ratio values must be within range: 1 to 127";
				return false;
			}
			if (schemeDestByteCount > schemeSrcByteCount) {
				message =
					"Mapping Ratio destination byte count (left-value) must be less than or equal the source byte count (right-value)";
				return false;
			}
			try {
				long lastOffset = length - 1;
				long sourceOffset = (schemeSrcByteCount * (lastOffset / schemeDestByteCount)) +
					(lastOffset % schemeDestByteCount);
				baseAddr.addNoWrap(sourceOffset);
			}
			catch (AddressOverflowException e) {
				message =
					"Insufficient space in byte-mapped source region at " + baseAddr.toString(true);
				return false;
			}
		}
		else if (blockType == MemoryBlockType.BIT_MAPPED) {
			try {
				baseAddr.addNoWrap((length - 1) / 8);
			}
			catch (AddressOverflowException e) {
				message =
					"Insufficient space in bit-mapped source region at " + baseAddr.toString(true);
				return false;
			}
		}
		return true;
	}
Model to manage adding a memory block.
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/memory/AddBlockModel.java