/*  CW for DC sample "print.cpp"  1998 Nov 2  */

/*
 *      Takashi Kashima
 *		Copyright © 1998 Metrowerks JAPAN R&D
 *		All rights reserved.
 *
 *		1999.01.21	for beta 1.5
 *		1998.11.25	for beta 1
 *
 */

#include "print.h"


#pragma	mark -
#pragma	mark *** class CPeripheral ***
//
//	CPeripheral class
//

CPeripheral::CPeripheral(Uint32 inPort)	:
	nPort(inPort),
	nInfoLoc(NJM_LOCATION( 0,  0))
{
}

void	CPeripheral::SetPrintLoc(Sint16 inX, Sint16 inY)
{
	nInfoLoc	= NJM_LOCATION( inX,  inY);
}

void	CPeripheral::print(void)
{
    njPrintC(nInfoLoc, "PORT NO:");
    njPrintH(NJM_LOCATION(NJM_GET_X(nInfoLoc) + 8,  NJM_GET_Y(nInfoLoc)), nPort, 8);
    njPrintPeripheralInfo(NJM_LOCATION(NJM_GET_X(nInfoLoc),  NJM_GET_Y(nInfoLoc) + 1), nPort);
}

#pragma	mark -
#pragma	mark *** class CPort0 ***
//
//	CPort0 class
//

CPort0::CPort0(void)	:
	nPortA(NJD_PORT_A0),
	nPortB(NJD_PORT_B0),
	nPortC(NJD_PORT_C0),
	nPortD(NJD_PORT_D0)
{
	nPortA.SetPrintLoc( 2,  4);
	nPortB.SetPrintLoc(22,  4);
	nPortC.SetPrintLoc( 2, 17);
	nPortD.SetPrintLoc(22, 17);
}

void	CPort0::print(void)
{
	nPortA.print();
	nPortB.print();
	nPortC.print();
	nPortD.print();
}

#pragma	mark -
#pragma	mark *** class CPrint ***
//
//	CPrint class
//

CPrint::CPrint(void)	:
	nStart(0),
	nCount(nStart)
{
}

CPrint::CPrint(Uint32 inStart)	:
	nStart(inStart),
	nCount(nStart)
{
}

void	CPrint::print(void)
{
	printCount();
	nPort.print();
}

void	CPrint::vsync(void)
{
	njWaitVSync();
}

void	CPrint::printCount(void)
{
	printStatus(nCount++);
}

void	CPrint::printStatus(Sint32 inCount)
{
    njPrintC(NJM_LOCATION(2,  2), "PRINT++ SAMPLE");
    njPrintH(NJM_LOCATION(20,  2), nStart, 8);
	njPrintH(NJM_LOCATION(30,  2), inCount, 8);
}

#pragma	mark -
#pragma	mark *** class CPrint2 ***
//
//	CPrint2 class
//

CPrint2::CPrint2(void)	:
	CPrint(0xFFFFFFFF)
{
}

CPrint2::CPrint2(Uint32 inStart)	:
	CPrint(inStart)
{
}

void	CPrint2::printCount(void)
{
	printStatus(nCount--);
}
