{/************************************************************************/}
{/* Get configuration switches the external register */}
{/* This is a dangerous routine because it turns off video clock */}
{/************************************************************************/}
procedure read_switches;
var
i,bits,switches,old_mode : word;
begin
switches := 0;
old_mode := get_mode;
{/* Writing to 3C2 disables video ! */}
write_register($3C2,$C); {/* Select interpretation */}
bits := read_register($3C2); {/* Get external register */}
bits := (bits and $10) shr 4; {/* Isolate switch bit */}
switches := bits or switches; {/* Add bit to switch */}
write_register($3C2,$8); {/* Select interpretation */}
bits := read_register($3C2); {/* Get external register */}
bits := (bits and $10) shr 3; {/* Isolate switch bit */}
switches := bits or switches; {/* Add bit to switch */}
write_register($3C2,$4); {/* Select interpretation */}
bits := read_register($3C2); {/* Get external register */}
bits := (bits and $10) shr 2; {/* Isolate switch bit */}
switches := bits or switches; {/* Add bit to switch */}
write_register($3C2,$0); {/* Select interpretation */}
bits := read_register($3C2); {/* Get external register */}
bits := (bits and $10) shr 1; {/* Isolate switch bit */}
switches := bits or switches; {/* Add bit to switch */}
write_register($3C2,$A6); {/* Select interpretation */}
set_mode(old_mode); {/* Restore 3c2 to proper value */}
writeln('Switch setting is ', switches, ' (decimal)');
end;