home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Interactive Guide
/
c-cplusplus-interactive-guide.iso
/
c_ref
/
csource4
/
225_01
/
deff4.c
< prev
next >
Wrap
Text File
|
1987-06-10
|
25KB
|
705 lines
/*-----------------------------------------------------------------*/
/* FILE: DEFF4.C
----
COMPILER: BDS C V 1.50
--------
WRITTEN: 22/10/85
-------
REVISED: 16/11/86
-------
VERSION: 1.4
-------
ADDED FCTs: B_TEST
---------- */
/* This file contains the following functions - */
/* */
/* SET_BIT PUT_ERROR UP_STR */
/* LOWER_STR ENTAB PLIST */
/* LIST_STATUS LISTS LISTD */
/* MAKE_FCB PEC_CLEAR HAZ_CLEAR */
/* BRIGHT NORMAL LINE(S) */
/* PRINT_U GO_TO OUT_CHAR */
/* ISNUM INKEY PRT_HEX */
/* VIDEO_CHAR B_TEST */
/*-----------------------------------------------------------------*/
/* BIOS Functions
--------------
W_BOOT CONST CONIN
CONOUT LIST_C SELDSK
SET_TRK SET_SEC SET_DMA
READ_SEC WRITE_SEC LISTST */
/*-----------------------------------------------------------------*/
/* */
/* all of which are described in the file DEFF4.TXT. */
/* */
/* WRITTEN: 14th July, 1986 */
/* ------- */
/* BIOS functions added September 27, 1986 */
/* Copyright 1986 by Cogar Computer Services Pty. Ltd. */
/* All rights reserved. */
/*-----------------------------------------------------------------*/
#include <pec.h> /* Required for these functions */
/*=================================================================*/
/* LIBRARY FUNCTION: B_TEST
Will test the nominated bit in a byte and return TRUE if it
is set ( = 1) or FALSE if it is not set. Note that "bit"
must be one of "B_ZERO" to "B_SEVEN" as per pec.h */
/*-----------------------------------------------------------------*/
char b_test(byte, bit)
int bit;
char byte;
{
int set_bit;
if(bit == 0)
set_bit = 0x1;
else if(bit == 1)
set_bit = 0x2;
else if(bit == 2)
set_bit = 0x4;
else if(bit == 3)
set_bit = 0x8;
else if(bit == 4)
set_bit = 0x10;
else if(bit == 5)
set_bit = 0x20;
else if(bit == 6)
set_bit = 0x40;
else if(bit == 7)
set_bit = 0x80;
if((byte & set_bit) > 0)
return(1);
else return(0);
}
/*-----------------------------------------------------------------*/
/* SUBROUTINE ==> set_bit */
/* Will set the nominated BYTE in the file control block */
/* Choices are - */
/* R/O Read only */
/* R/W Read/Write (re-sets the bit) */
/* SYS System file */
/* DIR Directory (re-sets SYS bit) */
/* ARC Archive bit */
/* CPY Copy (re-sets Archive bit) */
/*-----------------------------------------------------------------*/
void set_bit(fcb_buf,str)
char fcb_buf[36], str[3];
{
up_str(str); /* convert to upper case */
if(strcmp(str,"R/O") == 0)
fcb_buf[9] = fcb_buf[9] | 0x80;
else if(strcmp(str,"R/W") == 0)
fcb_buf[9] = fcb_buf[9] & 0x7f;
else if(strcmp(str,"SYS") == 0)
fcb_buf[10] = fcb_buf[10] | 0x80;
else if(strcmp(str,"DIR") == 0)
fcb_buf[10] = fcb_buf[10] & 0x7f;
else if(strcmp(str,"ARC") == 0)
fcb_buf[11] = fcb_buf[11] | 0x80;
else if(strcmp(str,"CPY") == 0)
fcb_buf[11] = fcb_buf[11] & 0x7f;
else put_error(str);
if(set_attributes(fcb_buf) == -1)
printf("\nUnable to find the nominated file.\n");
}
/*-----------------------------------------------------------------*/
/* SUBROUTINE ==> put_error */
/* Used with set_bit */
/*-----------------------------------------------------------------*/
void put_error(string)
char *string;
{
printf("\n\nThe mode %s is unknown...terminating programme.", string);
exit();
}
/*-----------------------------------------------------------------*/
/* LIBRARY FILE == up_str */
/* Will convert a string to UPPER case ASCII */
/*-----------------------------------------------------------------*/
void up_str(s)
char *s;
{
short i;
i = 0;
while(s[i])
{
s[i] = toupper(s[i]);
i++;
}
s[i] = '\0';
}
/*-----------------------------------------------------------------*/
/* LIBRARY FILE == lower_str */
/* Will convert a NULL-terminated string to ASCII lower case */
/*-----------------------------------------------------------------*/
void lower_str(s)
char *s;
{
short i;
i = 0;
while(s[i])
{
s[i] = tolower(s[i]);
i++;
}
s[i] = '\0';
}
/*-----------------------------------------------------------------*/
/* LIBRARY FILE ==> ENTAB */
/* Will compensate for TAB characters on those printers which */
/* don't recognise the ASCII tab. Can be altered for different */
/* tab sizes, as needed. */
/*-----------------------------------------------------------------*/
char entab(position, size)
short position, size;
{
short tab_count;
for(tab_count = 0; tab_count <= size - position%size; tab_count++)
listc(SPACE);
tab_count--; /* Must go back one */
position = position + tab_count;
return(position);
}
/*-----------------------------------------------------------------*/
/* LIBRARY FILE ==> plist */
/* Will list one character to the line printer using the actual */
/* I/O port addresses. */
/* Presently configured for GODBOUT INTERFACER II board but can */
/* be modified for any "Centronics" connection provided the */
/* ports and the strobe signals are known. */
/* NOTE: The strobe signals used are those for the Itoh 8510 */
/* ---- printer. */
/* */
/* Written for BDS C but should be portable to other C's. */
/* Copyright 1986 by Cogar Computer Services Pty. Ltd. */
/*-----------------------------------------------------------------*/
/* INTERFACER II EQUATES */
/*-----------------------------------------------------------------*/
#define BASE_PORT 0x0c8 /* Interfacer II printer ports */
#define HAND_SHAKE BASE_PORT + 1 /* Handshaking port */
#define LIST_PORT HAND_SHAKE + 1 /* Printer data port */
/*-----------------------------------------------------------------*/
/* ITOH 8510 PRINTER EQUATES */
/*-----------------------------------------------------------------*/
#define OFF_STROBE 0x0ff /* To turn all strobes off */
#define IN_DATA 0x0bf /* Active, data input signal */
#define BUSY_INPUT 0x07f /* Active, input busy signal */
#define BUSY 0x080 /* Printer busy signal */
#define DELAY 100 /* 1 millisecond delay ?