//------------------------------------------------------------------- // backward.cpp // // This text-mode demo must be executed with 'root' privileges. // // programmer: ALLAN CRUSE // written on: 04 SEP 2003 //------------------------------------------------------------------- #include // for printf(), perror() #include // for open() #include // for exit() #include // for mman() #include // for iopl() int main( int argc, char **argv ) { int fd = open( "/dev/mem", O_RDWR ); if ( fd < 0 ) { perror( "/dev/mem" ); exit(1); } int base = 0x000A0000, size = (128<<10); // 128K int prot = PROT_READ | PROT_WRITE; int flag = MAP_FIXED | MAP_SHARED; void *mm = (void*)base; if ( mmap( mm, size, prot, flag, fd, base ) == MAP_FAILED ) { perror( "mmap" ); exit(1); } if ( iopl( 3 ) ) { perror( "iopl" ); exit(1); } // prologue outw( 0x0100, 0x3C4 ); // enter synchronous reset outw( 0x0402, 0x3C4 ); // write only to map 2 outw( 0x0704, 0x3C4 ); // use sequential addressing outw( 0x0300, 0x3C4 ); // leave synchronous reset outw( 0x0204, 0x3CE ); // select map 2 for reads outw( 0x0005, 0x3CE ); // disable odd-even addressing outw( 0x0006, 0x3CE ); // map starts at 0xA000:0000 // modify the contents of character generator ram unsigned char *vram = (unsigned char*)base; for (int i = 0; i < 32*256; i++) { unsigned char orig = vram[ i ], revs = 0; for (int j = 0; j < 8; j++) if ( orig & (1<