<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/usr/bin/perl
# $Id: sys2ansi.pl,v 1.3 1999/03/05 15:08:54 hpa Exp $
#
# Perl script to convert a Syslinux-format screen to PC-ANSI
#
@ansicol = (0,4,2,6,1,5,3,7);

while ( read(STDIN, $ch, 1) &gt; 0 ) {
    if ( $ch eq "\x1A" ) {	# &lt;SUB&gt; &lt;Ctrl-Z&gt; EOF
	last;
    } elsif ( $ch eq "\x0C" ) {	# &lt;FF&gt;  &lt;Ctrl-L&gt; Clear screen
	print "\x1b[2J";
    } elsif ( $ch eq "\x0F" ) {	# &lt;SI&gt;  &lt;Ctrl-O&gt; Attribute change
	if ( read(STDIN, $attr, 2) == 2 ) {
	    $attr = hex $attr;
	    print "\x1b[0;";
	    if ( $attr &amp; 0x80 ) {
		print "5;";
		$attr &amp;= ~0x80;
	    }
	    if ( $attr &amp; 0x08 ) {
		print "1;";
		$attr &amp;= ~0x08;
	    }
	    printf "%d;%dm",
	    $ansicol[$attr &gt;&gt; 4] + 40, $ansicol[$attr &amp; 7] + 30;
	}
    } else {
	print $ch;
    }
}

</pre></body></html>