/************************************************************************/ /* Get configuration switches the external register */ /* This is a dangerous routine do not run! */ /************************************************************************/ read_switches() { int i, bits, switches = 0, old_mode; old_mode = get_mode(); /* Writing to 3C2 disables video ! */ write_register(0x3C2,0x1C); /* Select interpretation */ bits = read_register(0x3C2); /* Get external register */ bits = (bits & 0X10) >> 4; /* Isolate switch bit */ switches = bits | switches; /* Add bit to switch */ write_register(0x3C2,0x18); /* Select interpretation */ bits = read_register(0x3C2); /* Get external register */ bits = (bits & 0X10) >> 3; /* Isolate switch bit */ switches = bits | switches; /* Add bit to switch */ write_register(0x3C2,0x14); /* Select interpretation */ bits = read_register(0x3C2); /* Get external register */ bits = (bits & 0X10) >> 2; /* Isolate switch bit */ switches = bits | switches; /* Add bit to switch */ write_register(0x3C2,0x10); /* Select interpretation */ bits = read_register(0x3C2); /* Get external register */ bits = (bits & 0X10) >> 1; /* Isolate switch bit */ switches = bits | switches; /* Add bit to switch */ set_mode(old_mode); /* Restore 3c2 to proper value */ printf("\nSwitch setting is %x hex", switches); }