Skip to content

N: SIO Command 'R' Read

Thomas Cherryhomes edited this page May 9, 2020 · 4 revisions

N: SIO Command READ ($52) ['R']

Description

Fetch the number of bytes requested from the protocol channel opened previously by the OPEN command. an ERROR will result if too many bytes are requested, so a STATUS should be sent beforehand to determine the # of bytes to receive.

Parameters

DCB Value
DDEVIC $71
DUNIT $01 - $04
DCOMND $52 'R'
DSTATS $40
DBUF NULL
DTIMLO $0F
DBYT # of bytes to return
DAUX1 # of bytes to return LO
DAUX2 # of bytes to return HI

Examples

CC65

/**
 * io_main() - The IO main loop
 */
void io_main(void)
{
  if (xmit_buffer_len>0)
    {
      OS.dcb.ddevic=0x71;
      OS.dcb.dunit=1;
      OS.dcb.dcomnd='W';
      OS.dcb.dstats=0x80;
      OS.dcb.dbuf=&xmit_buffer;
      OS.dcb.dtimlo=0x0f;
      OS.dcb.dbyt=xmit_buffer_len;
      OS.dcb.daux1=xmit_buffer_len;
      OS.dcb.daux2=0;
      siov();

      xmit_buffer_len=0;
      return;
    }

  if (trip==0)
    return;

  // Get # of bytes waiting
  OS.dcb.ddevic=0x71;
  OS.dcb.dunit=1;
  OS.dcb.dcomnd='S';
  OS.dcb.dstats=0x40;
  OS.dcb.dbuf=&status;
  OS.dcb.dtimlo=0x0f;
  OS.dcb.dbyt=4;
  OS.dcb.daux=0;
  siov();

  bw=(status[1]<<8)+status[0];
  connected=status[2];

  // These functions are all I needed to change to port over to the N: device.

  if (bw>0)
    {
      // Do a read into into recv buffer and ShowPLATO
      OS.dcb.ddevic=0x71;
      OS.dcb.dunit=1;
      OS.dcb.dcomnd='R';
      OS.dcb.dstats=0x40;
      OS.dcb.dbuf=&recv_buffer;
      OS.dcb.dbyt=bw;
      OS.dcb.daux=bw;
      siov();
      ShowPLATO((padByte *)recv_buffer, bw);
      bw=trip=0;
    }

  if (connected==0)
    {
      io_done();
    }

  PIA.pactl |= 1;
}

See Also

Put other related command links here.

Clone this wiki locally