Skip to content

Instantly share code, notes, and snippets.

@jacobly0
Last active August 25, 2016 18:39
Show Gist options
  • Save jacobly0/628a0077fbffe819b25f123d21e91ddb to your computer and use it in GitHub Desktop.
Save jacobly0/628a0077fbffe819b25f123d21e91ddb to your computer and use it in GitHub Desktop.
Screen Shift
void ShiftUp(unsigned amt) {
char *dst = currDrawingBuff + xmin + ymin * lcdWidth;
char *src = dst + amt * lcdWidth;
unsigned times = ymax - ymin - amt;
do {
ldir(dst, src, xmax - xmin);
dst += lcdWidth;
src += lcdWidth;
} while (--times);
}
void ShiftDown(unsigned amt) {
char *dst = currDrawingBuff + (xmax - 1) + (ymax - 1) * lcdWidth;
char *src = dst - amt * lcdWidth;
unsigned times = ymax - ymin - amt;
do {
lddr(dst, src, xmax - xmin);
dst -= lcdWidth;
src -= lcdWidth;
} while (--times);
}
void ShiftLeft(unsigned amt) {
char *dst = currDrawingBuff + xmin + ymin * lcdWidth;
char *src = dst + amt;
unsigned times = ymax - ymin;
do {
ldir(dst, src, xmax - xmin - amt);
dst += lcdWidth;
src += lcdWidth;
} while (--times);
}
void ShiftRight(unsigned amt) {
char *dst = currDrawingBuff + (xmax - 1) + (ymax - 1) * lcdWidth;
char *src = dst - amt;
unsigned times = ymax - ymin;
do {
lddr(dst, src, xmax - xmin - amt);
dst -= lcdWidth;
src -= lcdWidth;
} while (--times);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment