Advertisement
PierrotLL

Scrolling functions

Jun 10th, 2011
455
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.83 KB | None | 0 0
  1. void vertical_scroll(char* buffer, int shift) {
  2.     int i, j;
  3.     char column[64];
  4.     shift %= 64;
  5.     for(i=0 ; i<16 ; i++) {
  6.         for(j=0 ; j<64 ; j++) column[j] = buffer[(j<<4)+i];
  7.         for(j=0 ; j<64 ; j++) buffer[(j<<4)+i] = column[(j-shift+64)&63];
  8.     }
  9. }
  10.  
  11. void horizontal_scroll(unsigned char* buffer, int shift) {
  12.     int i, j;
  13.     unsigned char line[16], Bshift, next;
  14.     unsigned short word;
  15.     shift %= 128;
  16.     Bshift = 8-(shift&7);
  17.     for(i=0 ; i<64 ; i++) {
  18.         for(j=0 ; j<16 ; j++) line[j] = buffer[(i<<4)+((j-(shift>>3)+15)&15)];
  19.         next = line[15];
  20.         buffer[(i<<4)+15] = 0;
  21.         for(j=15 ; j>0 ; j--) {
  22.             word = next << Bshift;
  23.             next = line[j-1];
  24.             buffer[(i<<4)+j] |= *((char*)&word+1);
  25.             buffer[(i<<4)+j-1] = *((char*)&word);
  26.         }
  27.         word = next << Bshift;
  28.         buffer[(i<<4)] |= *((char*)&word+1);
  29.         buffer[(i<<4)+15] |= *((char*)&word);
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement