*copyc OSD$DEFAULT_PRAGMATS

MODULE iim$term_char_utilities;

?? PUSH (LISTEXT := ON) ??
*copyc IIT$CONNECTION_DESCRIPTION
*copyc MLD$MEMORY_LINK_DECLARATIONS
?? POP ??

?? TITLE := 'PROCEDURE iip$convert_upline_term_char', EJECT ??

  PROCEDURE [XDCL, #GATE] iip$convert_upline_term_char (pib: ^cell;
    pob: ^cell;
    input_block_length: mlt$message_length);

{  PURPOSE:
{    The purpose of this procedure is to convert a C170 Upline Terminal
{    Charactistics Message  received from the NAM to a C180 Upline Terminal
{    Characteristics Message which can be delivered to the caller.
{  DESIGN:
{    The conversion is accomplished by moving 4 bits at a time from the
{    C170 Upline Terminal Characteristics Message to the C180 Upline Terminal
{    Characteristics Message while skipping the upper 4 bits of each word of
{    the C170 Upline Terminal Characteristics Message.
{

    VAR
      limit: integer,
      pins,
      pons: ^iit$nibble_string,
      i,
      j: integer;

    pins := pib;
    pons := pob;

{ Copy the first 22 half bytes asis.  This is header information.

    FOR i := 0 TO 21 DO
      pons^ [i] := pins^ [i];
    FOREND;

{ Convert the rest of the message starting at the 22nd half byte, the first
{ FN/FV pair.

    j := 22;
    i := 21;
    limit := input_block_length;

  /move_half_bytes/
    WHILE limit <> 0 DO
      IF i MOD 16 = 0 THEN
        i := i + 1;
        CYCLE /move_half_bytes/;
      IFEND;
      pons^ [j] := pins^ [i];
      j := j + 1;
      i := i + 1;
      limit := limit - 1;
    WHILEND /move_half_bytes/;

  PROCEND iip$convert_upline_term_char;

?? TITLE := 'PROCEDURE iip$convert_downline_term_char', EJECT ??

  PROCEDURE [XDCL, #GATE] iip$convert_downline_term_char (pib: ^cell;
    pob: ^cell;
    input_block_length: mlt$message_length;
    VAR output_block_length: mlt$message_length);

{  PURPOSE:
{    The purpose of this procedure is to convert a C180 Downline Terminal
{    Characteristics Message to a C170 Downline Characteristics Message which
{    can be sent to the NAM.
{  DESIGN:
{    The conversion is accomplished by moving 4 bits at a time from the
{    C180 Downline Terminal Characteristics Message to the C170 Downline
{Terminal
{    Characteristics Message while inserting the upper 4 bits of each C170
{    word.
{

    VAR
      pins,
      pons: ^iit$nibble_string,
      i,
      j: integer;

    pins := pib;
    pons := pob;

{ Copy the first two words without conversion.

    FOR i := 0 TO 31 DO
      pons^ [i] := pins^ [i];
    FOREND;

{ Convert the rest of the message starting at the first terminal
{ characteristics pair which starts at the 4th byte of the second
{ word.

    j := 21;

    FOR i := 22 TO 2 * input_block_length DO
      IF j MOD 16 = 0 THEN
        pons^ [j] := 0;
        j := j + 1;
      IFEND;
      pons^ [j] := pins^ [i];
      j := j + 1;
    FOREND;

    output_block_length := (j + 1) DIV 2;

  PROCEND iip$convert_downline_term_char;

MODEND iim$term_char_utilities;
