/*********************************************************************
*
*	TITLE:	DMOHLP
*
*	DATE:	10-05-90
*
*	ABSTRACT: This module contains help menus and text for the demo
*                 program for the DOSRMX Real Time Extensions.
*
*
*   MODIFIED: 
*
***********************************************************************/

/*
 *			 INTEL CORPORATION PROPRIETARY INFORMATION
 *
 *		  This software is supplied under the terms of a 
 *		  license agreement or nondisclosure agreement with
 *		  Intel Corporation and may not be copied or disclosed
 *		  except in accordance with the terms of that agreement.
 *
 */
#include <stdio.h>
#include <stdlib.h>

#define PAGE_SIZE 20
#define TRUE 0xff
#define FALSE 0x00

static char help_menu_0[] = {
"\n\n"
"                           Help Menu\n"
"                           =========\n\n"
"                  1. Mailboxes (Objects) Functions\n\n"
"                  2. Mailboxes (data) Functions\n\n"
"                  3. Semaphore Functions\n\n"
"                  4. Segment Functions\n\n"
"                  5. Descriptor Functions\n\n"
"                  6. Data Transfer Functions\n\n"
"                  7. RETURN to previous menu\n\n"
"                  Enter option (1 to 7) :- "};

static char error_message_0[] = {
"\n\n"
"Only characters between '1' and '7' are valid\n"};

static   char  help_function_1a[]  =  {  "\n\n"
"The Mailbox (object)  functions allow you to send and receive\n"
"objects  (segment or descriptor)  from a named  mailbox.  The\n"
"mailbox  may have been created by  either this program or the\n"
#ifdef RMX
"DOS version of  this program.\n"
#else
"RMX version of  this program.\n"
#endif
"There are  two  options,  SEND  Object  and  RECEIVE  object,\n"
"described as follows:-\n" };
static   char  help_function_1b[]  =  {  "\n\n"
"SEND OBJECT TO MAILBOX  sends  a  named  object  (segment  or\n"
"descriptor) to a named mailbox. If the mailbox doesn't  exist\n"
"then it is created.  If the named object doesn't exist then a\n"
"segment is created for the object.\n"};
static   char  help_function_1c[]  =  {  "\n\n"
"RECEIVE OBJECT  FROM MAILBOX requests an  object from a named\n"
"mailbox. If the received object is a segment then its name is\n"
"displayed otherwise the TOKEN is displayed.  If there are  no\n"
"objects E$TIME is displayed. If the mailbox  doesn't exist an\n"
"error message is displayed.\n"};

static char help_function_2a[] = {
"\n\n"
"The  Mailbox (data) functions allow you to send and receive a\n"
"string of  text (127 characters max) to  and from a data type\n"
"mailbox.   The mailbox may  have been created  by either this\n"
#ifdef RMX
"program or the  DOS version of  this program.   There are two\n"
#else
"program or the  RMX version of  this program.   There are two\n"
#endif
"options, SEND  and  RECEIVE  data,  these  are  described  as\n"
"follows:-\n"};
static char help_function_2b[] = {
"\n\n"
"SEND  DATA  TO  MAILBOX  allows  you  to  send  a  string  of\n"
"characters to  a data mailbox.  The  string must be no longer\n"
"than 127 chacters and is entered at the prompt, :-.  The text\n"
"entry is terminated by a carrage return.  If the data mailbox\n"
"doesn't exist then one will be created.\n"};
static char help_function_2c[] = {
"\n\n"
"RECEIVE DATA  FROM MAILBOX receives  a string of  text from a\n"
"data mailbox and displays it on the the screen along with the\n"
"size of the  string.  If  the mailbox doesn't  exist an error\n"
"message is displayed.\n"};

static char help_function_3a[] = {
"\n\n"
"The semaphore  functions allow you to  send and receive units\n"
"to and from a semaphore.  The semaphore may have been created\n"
#ifdef RMX
"by either  this program or  the DOS version  of this program.\n"
#else
"by either  this program or  the RMX version  of this program.\n"
#endif
"There are two options, SEND  and  RECEIVE  units,  these  are\n"
"described as follows:-\n"};
static char help_function_3b[] = {
"\n\n"
"SEND  UNITS TO SEMAPHORE allows you to send a number of units\n"
"to a named semaphore.  The semaphore will accept a maximum of\n"
"10 units and the number to be sent are entered when prompted.\n"
"If the semaphore doesn't exist then it is created.\n"};
static char help_function_3c[] = {
"\n\n"
"RECEIVE UNITS FROM A SEMAPHORE receives a requested number of\n"
"units from a named semaphore and displays the renaming number\n"
"of units at the semaphore.  If the semaphore doesn't exist an\n"
"error message is displayed.\n"};

static char help_function_4a[] = {
"\n\n"
"The segment functions allow you to create, delete and display\n"
"a named PVAM segment.  The PVAM segment may have been created\n"
#ifdef RMX
"by either  this program or  the DOS version  of this program.\n"
#else
"by either  this program or  the RMX version  of this program.\n"
#endif
"There  are three options,  CREATE, DELETE and  DISPLAY a PVAM\n"
"segment these are described as follows:-\n"};
static char help_function_4b[] = {
"\n\n"
"CREATE A PVAM SEGMENT allows  you  to  create  a  named  PVAM\n"
"segment  of any size.  This segment  can be used to copy real\n"
"mode  memory into or can be used as the source to copy a PVAM\n"
"memory to real mode memory (NOTE this can crash DOS if copied\n"
"to  the wrong place).  The PVAM  can also be passed to object\n"
"mailboxes and displayed by the DISPLAY PVAM function.\n"};
static char help_function_4c[] = {
"\n\n"
"DELETE A PVAM SEGMENT allows  you  to  delete  a  named  PVAM\n"
"segment OR named descriptor.  The segment or descriptor could\n"
#ifdef RMX
"have  been created by this program or the DOS version of this\n"
#else
"have  been created by this program or the RMX version of this\n"
#endif
"program.\n"};
static char help_function_4d[] = {
"\n\n"
"DISPLAY  A PVAM SEGMENT allows you  to display a PVAM segment\n"
"or  descriptor.  This is displayed in blocks of 160 bytes max\n"
"and is  displayed as lines of 16  bytes followed by the valid\n"
"ASCII characters for each byte or a dot (.) if no valid.  The\n"
"user  is prompted for a  key input to continue  or quit (Q or\n"
"q).  The  segment or descriptor  is looked up  under its user\n"
"name.\n"};


static char help_function_5a[] = {
"\n\n"
"The descriptor functions allow  you  to  create,  delete  and\n"
"display a  descriptor.  The descriptor  may have been created\n"
#ifdef RMX
"by either  this program or  the DOS version  of this program.\n"
#else
"by either  this program or  the RMX version  of this program.\n"
#endif
"There  are  three  options,  CREATE,  DELETE  and  DISPLAY  a\n"
"descriptor, these are described as follows:-\n\n"
"CREATE A  DESCRIPTOR allows you to  create a named descriptor\n"
"of any size and absolute address.\n"
};

static char help_function_5b[] = {
"\n\n"
"DELETE A DESCRIPTOR allows you to delete a named PVAM segment\n"
"OR named descriptor. The segment or descriptor could have been\n"
#ifdef RMX
"created by this program or the DOS version of this program.\n\n"
#else
"created by this program or the RMX version of this program.\n\n"
#endif
};

static char help_function_5c[] = {
"\n\n"
"DISPLAY  A DESCRIPTOR allows you to display a PVAM segment or\n"
"descriptor.  This is displayed in blocks of 160 bytes max and\n"
"is displayed as lines of 16 bytes followed by the valid ASCII\n"
"characters  for each byte or a dot (.) if no valid.  The user\n"
"is prompted for a  key input to  continue  or  quit (Q or q).\n"
"The segment or descriptor  is looked up  under its user name.\n"
"The segment or descriptor could  have  been  created  by this\n"
#ifdef RMX
"program or the DOS version of this program.\n"};
#else
"program or the RMX version of this program.\n"};
#endif

static char help_function_6a[] = {
"\n\n"
"The  data transfer functions allow you to copy data from real\n"
"mode address space to a PVAM segment OR to copy PVAM segement\n"
"to real mode address space ( NOTE.  copying from PVAM segment\n"
"to real mode space  picked out  a random  could cause  DOS to\n"
"crash).  The two options are as follows : -\n"};
static char help_function_6b[] = {
"\n\n"
"COPY PVAM SEGMENT TO REAL MODE ADDRESS copies a named segment\n"
"to  a real mode  address that you  enter in at  the  keyboard\n"
"when  prompted.  The format is  real mode segment and offset.\n"
"NOTE.   This option  should be  used with  caution as  it can\n"
"corrupt DOS data structures and cause unpredictable results.\n"};
static char help_function_6c[] = {
"\n\n"
"COPY REAL MODE  ADDRESS TO  PVAM SEGMENT  copies a  real mode\n"
"address,  that you enter in at the keyboard when prompted, to\n"
"a named segment.  The format is real mode segment and offset.\n"};

/******************************************************************
*
*    TITLE: RQCreateMailbox
*
*    CALLING SEQUENCE: help_output(help_txt);
*
*    INTERFACE VARIABLES: help_txt POINTER - a pointer to an array or
*                                              characters that are the
*                                              help text.
*
*    PARAMETERS:
*
*    GLOBAL VARIABLES:
*
*
*    ABSTRACT: This function outputs the help text to the screen.
*
******************************************************************/
void help_output(char help_text[])
{
unsigned int line_count;
unsigned int char_count;
int more;

	clear_screen();

	char_count = 0;
	line_count = 0;
	more = ' ';

	while((help_text[char_count] != 0) && ((more != 'Q') || (more != 'q')))
	{
		if (line_count != PAGE_SIZE)
		{
			putchar(help_text[char_count]);

			if (help_text[char_count] == '\n')
			{
				++line_count; /* count lines */
				printf("     "); /* put a margin space in */
			}
		}
		else
		{
			printf("\n Press any key to continue");
			more = getche();
			line_count = 0;

			clear_screen();
		}
		++char_count; /* point to next char */
	}
	printf("\n Press any key to continue");
	more = getche();
}

/******************************************************************
*
*    TITLE: HELP_FUNCTIONS
*
*    CALLING SEQUENCE: help_functions;
*
*    INTERFACE VARIABLES: NONE
*
*    PARAMETERS: 
*
*    GLOBAL VARIABLES: 
*
*
*    ABSTRACT: This function provides the help menu for the demo
*              program for the Real Time Extensions.
*
******************************************************************/
void help_functions()
{
int forever;

	forever = 1;

	while (forever)
	{
		clear_screen();

		printf("%s",help_menu_0);

		
		switch (getche())
		{
			case '1':	help_output(help_function_1a);
						help_output(help_function_1b);
						help_output(help_function_1c);
						break;

			case '2':	help_output(help_function_2a);
						help_output(help_function_2b);
						help_output(help_function_2c);
						break;

			case '3':	help_output(help_function_3a);
						help_output(help_function_3b);
						help_output(help_function_3c);
						break;

			case '4':	help_output(help_function_4a);
						help_output(help_function_4b);
						help_output(help_function_4c);
						help_output(help_function_4d);
						break;

			case '5':	help_output(help_function_5a);
						help_output(help_function_5b);
						help_output(help_function_5c);
						break;

			case '6':	help_output(help_function_6a);
						help_output(help_function_6b);
						help_output(help_function_6c);
						break;

			case '7':	forever = 0;
						break;

			default:	error_message(error_message_0);
						break;
		}
	}
}
