//------------------------------------------------------------------- // dactable.cpp // // This program illustrates direct I/O programming of the VGA's // hardware registers: specifically, it inputs values currently // stored in the Digital-to-Analog Converter's color registers, // and then displays those values as hexadecimal R-G-B triples. // // compile using: $ make dacinput // // NOTE: You should execute 'iopl3' before launching this demo. // // programmer: ALLAN CRUSE // written on: 30 AUG 2005 //------------------------------------------------------------------- #include // for printf(), perror() #include // for exit() #include // for iopl(), inb(), outb() int main( int argc, char **argv ) { // set this task's I/O Privilege-Level to 3 if ( iopl( 3 ) ) { perror( "iopl" ); exit(1); } // read the 256 DAC color registers unsigned char dac[ 768 ]; outb( 0x00, 0x03C7 ); // initialize DAC Pixel Index for reading // input the (r,g,b) components for 256 color registers for (int i = 0; i < 768; i++) dac[ i ] = inb( 0x3C9 ); // display the color-registers as hexadecimal triples printf( "\n\tContents of the DAC Color-Table Registers: \n" ); for (int i = 0; i < 256; i++) { if ( ( i % 4 ) == 0 ) printf( "\n\t" ); printf( " %3d: ", i ); printf( "%02X-", dac[ 3*i + 0 ] ); printf( "%02X-", dac[ 3*i + 1 ] ); printf( "%02X ", dac[ 3*i + 2 ] ); } printf( "\n\n" ); }