/*	OXEGE4.C
**	
**	Direct Video RAM manipulation routines.  NOTE that
**	these routones are highly specific to the Osborne
**	Executive.
*/

#include "a:stdio.h"
#include "b:oxege.h"

#ifndef	SMALL
extern void bank1(), bank7();
#endif

/* 	POKE CHARACTER AND ATTRIBUTE INTO VIDEO RAM
*/
cpoke( line, column, character, attribute )
	int line, column, character, attribute;
	{
	fill( line, column, line, column, character, attribute );
	}

/*	POKE STRING INTO VIDEO RAM
*/
spoke( line, column, string, attribute )
	int line, column, attribute;
	char *string;
	{
/*	char *chptr; */
/*	int c1, inverse; */
/*	c1 = column; */
/*	inverse = 0; */
	if ( attribute % 16 == NULL ) { invert( string ); }
	fill( line, column, line, column + strlen( string )-1,
		' ', attribute );
	bank( 7 );
	memmov( string, VIDEO_RAM+(line*128)+column, strlen( string ) );
	bank( 1 );
/*
	chptr = string;
	while ( *chptr != 0 )
		{
		cpoke( line, c1, *chptr | inverse, attribute );
		++c1;
		++chptr;
		}
*/
	}

/*	INVERT STRING (CONVERT TO INVERSE VIDEO)
*/
invert( string )
	char string[];
	{
	int counter;
	counter = 0;
	while( string[counter] != NULL )
		{
		string[counter] = string[counter] | ATTINV ;
		++counter;
		}
	}


/*	LOGO
**
**	Osborne LOGO using OXEGE.CHR
*/
logo( l, c )
	int l, c;
	{
	int l1, c1;
	char ch;
	l1 = l;
	c1 = c;
	ch = 21;
	while ( c1 < c+5 )
		{
		cpoke( l1, c1, ch, ATTDIM | ATTALT );
		++ch;
		++c1; 
		}
	++l1;
	c1 = c;
	ch = 85;
	while ( c1 < c+5 )
		{
		cpoke( l1, c1, ch, ATTDIM | ATTALT );
		++ch;
		++c1;
		}
	}

/*	DISPLAY LARGE DIGIT
*/
bigdigit( number, line, column )
	int number, line, column;
	{
	cpoke( line,   column,   number*2    | ATTINV, ATTDIM | ATTALT );
	cpoke( line,   column+1, number*2+1  | ATTINV, ATTDIM | ATTALT );
	cpoke( line+1, column,   number*2+64 | ATTINV, ATTDIM | ATTALT );
	cpoke( line+1, column+1, number*2+65 | ATTINV, ATTDIM | ATTALT );
	}

/* 	SWITCH TO BANK 7 OR BACK TO 1 */
bank( number )
	int number;
	{
	if ( number == 1 )
	  {
	  ;
#ifdef	SMALL
#asm
		mvi	a,1
		out 	0
		ret
#endasm
#endif
#ifndef	SMALL
	  bank1();
#endif
	  }

	if ( number == 7 )
	  {
	  ;
#ifdef	SMALL
#asm
		mvi	a,65
		out	0
		ret
#endasm
#endif
#ifndef	SMALL	  
	bank7();
#endif
	  }

	}

#ifdef	SMALL
bank1()
	{
	;
#asm
	.z80
	ld	a,1
	out	(0),a
	ret
	.8080
#endasm
	;
	}

bank7()
	{
	;
#asm
	.z80
 	ld	a,65
	out	(0),a
	ret
	.8080
#endasm
	;
	}

#endif

et
	.8080