//----------------------------------------------------------------
//	seq5demo.cpp
//
//	In this experiment, every possible 8-bit value is output
//	to the SiS 315's Extended Sequencer Register 5, and then 
//	the value read back is displayed in hexadecimal format.
//
//	programmer: ALLAN CRUSE
//	written on: 13 OCT 2003
//----------------------------------------------------------------

#include <stdio.h>	// for printf(), perror()
#include <stdlib.h>	// for exit()
#include <sys/io.h>	// for iopl()

#define TSEQ 0x3C4

int main( void )
{
	if ( iopl( 3 ) ) { perror( "iopl" ); exit(1); }

	printf( "\n\n\t\tSiS 315 Extended Sequencer Register 5 \n" );
	printf( "\n\t\t\t   READBACK RESULTS \n" );

	printf( "\n\t    " );
	for (int i = 0; i < 16; i++) printf( "%02X ", i );

	for (int i = 0; i < 256; i++)
		{
		if ( ( i % 16 ) == 0 ) printf( "\n\t%02X: ", i );
		outw( (i<<8)|5, TSEQ );
		int	inval = inw( TSEQ );
		printf( "%02X ", inval>>8 );
		}
	printf( "\n\n\n" );	
}