flatIndex method

int flatIndex({
  1. required int bank,
  2. required int row,
})

Converts a bank and local row back into one flat index.

Implementation

int flatIndex({required int bank, required int row}) {
  _validateBank(bank);
  if (row < 0 || row >= bankEntryCount(bank)) {
    throw RangeError.range(row, 0, bankEntryCount(bank) - 1, 'row');
  }
  return switch (policy) {
    MemoryBankingPolicy.interleaved => row * bankCount + bank,
    MemoryBankingPolicy.contiguous => _contiguousBankBase(bank) + row
  };
}