//		  ÚÄÄÄÄÄÄÄ¿
//	ÄÄÄÄÄÄÄÄÄ>³ AVNER ³
//	ÄÄÄÄÄÄÄÄÄ>³  BEN  ³ÄÄÄÄÄÄ> Software Engineering Method
//		  ÀÄÄÄÄÄÄÄÙ
//	10 Dov-Hoz st. Tel-Aviv 63416 Israel tel. 972-3-221535

// The Screen NAVigator, ver 1.20 August 1990
// Copyright (c) 1990 by Avner Ben
// Snav is not, and never was, free software.
// for conditions for use refer to file "copyrigh.txt"

// The Screen Navigator is an object-oriented device-independent
// character-graphics driver package, written in the C++ language,
// distributed in the form of C++ source code.
// For further information refer to the documentation files.

// this simple example is intended as a template to be extended and modified
// by the user, provided the above title and copyright notice are unchanged
// and are not ommitted.

/***************************************************************************/

// demonstration part 1 - headers.
// a simplistic screen driver for the IBM-PC/compatiable running MS-DOS,
// implementing the virtual functions of the generic screen-driver supplied
// in snav-2.
// This simple demo is very device-specific, addressing the machine's
// internal architecture (it is a "misbehaved" program). It is also
// Zortech-specific, in assuming the existence of some names and include
// files.
// Do not compile with the /Ansi switch on, because dos.h uses far-pointers.

// 28.8.89 avner ben coded.
// 13.7.90 last update by avner ben.

// site history (of this copy):
// __.__.__: __________________

#ifndef DEMO1_H

#define DEMO1_H
#ifndef SNAV2_H
#include "/mtad/snav/snav2.hpp"
#endif

struct save_screen {	// assumes pc architecture (contigous, memory-mapped)
	char *s;	// line assumed to be byte array in memory
	save_screen *suc; // each line stored sperate (for partial screen)
	~save_screen(void);
};

struct	vd_char {				 // video cell, pc-style
	char c;
	unsigned char color;
};

class memory_mapped_pc_screen : public panel
{ // implementation of the generic class panel, assuming PC architecture

	private :
		vd_char *vdc, *stvdc;
		save_screen *svbuf;
		unsigned int color_code;	// internal-format color combi

		color_ind &decode_color(unsigned int color_code);
		unsigned int encode_color(color_ind &color);

	public :
		memory_mapped_pc_screen(square_pos *window=NULL,
		 boolean wrap_around=FALSE);
		 // default size 1:1x25:80
		~memory_mapped_pc_screen(void);

		char get_c(point_pos *pt);
		 // get char displayed in specified position (no kbd input)
		void put_c(char c, point_pos *pt, direction *dir);
		 // write a character on screen
		void put_color(color_ind &at, point_pos *pt);
		 // set color locally
		void put_attr(vd_attr at, point_pos *pt);
		 // toggle attribute in specified/cursor position
		void put_background(vd_clr colornum, point_pos *pt);
		 // set background color in specified/cursor position
		void put_forground(vd_clr colornum, point_pos *pt);
		 // set forground color in specified/cursor position
		boolean get_attr(vd_attr at, point_pos *pt);
		 // retrieve color locally
		color_ind &get_color(point_pos *pt);
		 // retrieve color locally
		void posit(point_pos *pt);
		 // position cursor
		void fix(void);
		void save(void);
		void restore(void);
		void clear_save_area(void);
		unsigned int ask_cursor(void);
		void set_cursor(unsigned int cursor_type);
		unsigned int hide_cursor(void);
};

#endif

