public Record(List<Integer> values) {
    if (values.size() == 0)
      throw new IllegalArgumentException("value list empty.");
    if (values.size() > 256 * 16)
      throw new IllegalArgumentException("value list size " + values.size() + " too large.");

    int numLoops = (1 + (values.size() - 1) / 16) % 256;
    int offset = ((16 - values.size() % 16) % 16) * 6;

    inputMap.put(36, toJoypadInput1(numLoops));
    inputMap.put(52, toJoypadInput2(numLoops));
    inputMap.put(64, toJoypadInput1(offset));
    inputMap.put(80, toJoypadInput2(offset));
    
    int curCycles = 116;
    for (int i = 0; i < values.size(); i++) {
      inputMap.put(curCycles, toJoypadInput1(values.get(i)));
      inputMap.put(curCycles + 16, toJoypadInput2(values.get(i)));

      curCycles += 40;
      if ((values.size() - i - 1) % 16 == 0)
        curCycles += 16;
    }
    cycleCount = curCycles + 12;
    if (cycleCount != getCycleCount(values.size()))
      throw new RuntimeException("cycle count " + cycleCount + "does not match calculation of " + getCycleCount(values.size()));
  }