dartSignedIntTo16BitSigned static method

int dartSignedIntTo16BitSigned(
  1. int val
)

Takes any Dart val between -32768 & 32767 and makes a zmachine-readable 16-bit signed 'word' from it.

Z-Machine Spec Reference

2.2

Implementation

static int dartSignedIntTo16BitSigned(int val) {
  if (val < -32768 || val > 32767) {
    throw GameException("Signed 16-bit int is out of range: $val");
  }

  if (val > -1) return val;

  return 65536 - val.abs();
}