/*FILE HEADER**************************************************************
 *
 *  File name		: $Id$
 *  RCS Revision Number	: $Revision: 1.1 $
 *  Last Modified	: $Date: 94/10/28 09:23:33 $
 *  CSCI name		: Real-Time Graphics System - Applications Interface
 *  CSC name		: All functions
 *  Notes:
 *      This file contains code used to debug and test the SVME-770 RTGS.
 *      This code is provided as an example of how to call the RTGS functions
 *      from a host application.
 *  History		:
 *      Created 94/01/17 by Jeff Sanderson
 *
 *END FILE HEADER*********************************************************/

#include "dy4std.h"
#include "es.h"
#include "css.h"

#include "rtgs_ai.h"
#include "video.h"
#include "colours.h"

#include "test.h"


void test_planmask( void );
/*-----------------------------------------------------------------------*/

void test_planmask( void )
{
    int i;

    init( "Plane masking test" );
    Clear_screen( 3, 0, 0 );
    
    for( i = 0 ; i < 0x100 ; i++ )
    {
        Set_colour_representation(0, i, 0x00, 0x00, 0x00 );
    }

    Set_colour_representation(0, 0xFF, 0xFF, 0x00, 0x00 );
    Set_foreground_colour( 0xFF );
    Draw_filled_rectangle( 0x0000, 0x0000,  0x0040, 0x0040);

    Set_colour_representation(0, 0x01, 0xBF, 0x3F, 0x00 );
    Set_foreground_colour( 0x01 );
    Draw_filled_rectangle( 0x0040, 0x0000,  0x0080, 0x0040);

    Set_colour_representation(0, 0x02, 0x7F, 0x7F, 0x00 );
    Set_foreground_colour( 0x02 );
    Draw_filled_rectangle( 0x0080, 0x0000,  0x00C0, 0x0040);

    Set_colour_representation(0, 0x04, 0x3F, 0xBF, 0x00 );
    Set_foreground_colour( 0x04 );
    Draw_filled_rectangle( 0x00C0, 0x0000,  0x0100, 0x0040);

    Set_colour_representation(0, 0x08, 0x00, 0xFF, 0x00 );
    Set_foreground_colour( 0x08 );
    Draw_filled_rectangle( 0x0100, 0x0000,  0x0140, 0x0040);

    Set_colour_representation(0, 0x10, 0x00, 0xBF, 0x3F );
    Set_foreground_colour( 0x10 );
    Draw_filled_rectangle( 0x0140, 0x0000,  0x0180, 0x0040);

    Set_colour_representation(0, 0x20, 0x00, 0x7F, 0x7F );
    Set_foreground_colour( 0x20 );
    Draw_filled_rectangle( 0x0180, 0x0000,  0x01C0, 0x0040);

    Set_colour_representation(0, 0x40, 0x00, 0x3F, 0xBF );
    Set_foreground_colour( 0x40);
    Draw_filled_rectangle( 0x01C0, 0x0000,  0x0200, 0x0040);

    Set_colour_representation(0, 0x80, 0x00, 0x00, 0xFF );
    Set_foreground_colour( 0x80 );
    Draw_filled_rectangle( 0x0200, 0x0000,  0x0240, 0x0040);


    Set_plane_mask( 0 );
    Set_foreground_colour( BLACK );
    Draw_filled_rectangle(  0x00 ,0x40, 0x40 , 0x80);

    Printf("Calling set plane mask 0x%x\n",0 );
    Set_plane_mask(0);
    Set_foreground_colour( 0xFF );
    Draw_filled_rectangle(  0x00 ,0x40, 0x40 , 0x80);
    Key_wait();

    for( i = 0 ; i < 9 ; i++ )
    {
        Set_plane_mask( 0 );
	Set_foreground_colour( BLACK );
        Draw_filled_rectangle((( i + 1 ) * 0x40 ), 0x40, 
                              ((( i + 1 ) * 0x40 ) + 0x40 ), 0x80);

        Printf("Calling set plane mask 0x%x\n",( ~( 1 << i ) & 0xFF ));
        Set_plane_mask(( ~(1 << i) & 0xFF ));
	Set_foreground_colour( 0xFF );
        Draw_filled_rectangle((( i + 1 ) * 0x40 ), 0x40, 
                              ((( i + 1 ) * 0x40 ) + 0x40 ), 0x80);
        Key_wait();
    }
}

/*-----------------------------------------------------------------------*/
