Skip to content

Instantly share code, notes, and snippets.

@cbmeeks
Last active June 3, 2017 06:54
Show Gist options
  • Save cbmeeks/d38d2ddca700e5dd9bea to your computer and use it in GitHub Desktop.
Save cbmeeks/d38d2ddca700e5dd9bea to your computer and use it in GitHub Desktop.
ZX Spectrum Pixel Address Calculator
var addr = function(L, C, R) {
return 16384 + 2048 * Math.floor(L / 8) + 32 * (L - 8 * Math.floor(L / 8)) + 256 * R + C;
};
@cbmeeks
Copy link
Author

cbmeeks commented Nov 24, 2015

L = Line Number
C = Column Number
R = Row Number (0 - 7) within the Line

@cbmeeks
Copy link
Author

cbmeeks commented Nov 24, 2015

hexString = addr.toString(16);

and reverse the process with:

yourNumber = parseInt(hexString, 16);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment