/*
 *      Driver file for Stuart James Systems 6809
 *      - Use with UMIST.def
 */


sjs_move(srow, scol)
register int srow, scol;
 {  /* tilde, ^A, col, row */
    ttyout('~');
    ttyout(1);
    ttyout(scol);
    ttyout(srow);
/*    sjs_pad(); */
 }

int sjs_setup()
 {  ictab[011] = ectab[011] = RIGHT;
    ictab[012] = DOWN;
    ictab[013] = UP;
    ictab[126] = ectab[126] = TWO;
 }

char sjs_intwo(c)
register char c;
 { return (c=='~' ? '^' : c); }

char sjs_outtwo(c)
register char c;
 { return (c=='^' ? '~' : c); }


#define PADCOUNT 200

sjs_pad()
 {  register int i;
/*    for (i=1; i<=PADCOUNT; i++) ttyout('\000'); */
        sleep(1);
 }

/*
int sjs_special(typein,c) int typein; register char c; {
register char ch;

if (c != '\033') {
 editerror("character %o given to sjs special",c);
 return(IGN);
 }
if (typein) {
 ch = ttyin();
 switch(ch) {
  case 033:
  case 'B': return(ENTERedit);
  case 'C': return(RIGHT);
  case 'D': return(LEFT);
  }
 if (mode!=INMODE) {complain(); return(IGN);}
 switch(ch) {
  case '@': return(DOWN);
  case 'A': return(UP);
  case 'H': return(TOPSCREEN);
  case '_': return(BOTSCREEN);
  case 'K': return(LINEERASE);
  default:  complain(); return(IGN);
  }
 }
else return(IGN);
}
*/


struct TERMINAL sjs_ter =
 {  /* nrows, ncols - size of the screen */
    TER_ROWS, TER_COLS,

    /* up, left, c_MODIFY, c_CONTROL, c_BLOB - single characters */
    { '\013', '\010', '@', 0200|'^', 0200|' ' },
        /* onechar */

    /* rollup, pushdown, pushup, pulldown, pullup STRINGS */
    /* and hardscroll boolean */
    /* you MUST have rollup */
    { "\n", 0, 0, 0, 0, false },
        /* scrseq */

    /* scrollup, scrolldown PROCEDURES */
    /* scr1_ is pushup, pulldown */
    /* scr2_ is pushdown, pullup */
    /* scr3_ is both */
    /* scr0_ is neither (and in that case hardscroll is false) */
    scr0_up, scr0_down,

    /* splitdown, splitup, joindown, joinup STRINGS */
    { 0, 0, 0, 0 },
        /* splitseq */

    /* split_row, join_row PROCEDURES */
    split0, join0,

    /* clearscreen, *clearhead, *cleartail STRINGS */
    /* I assume ^L for clear screen, but it isn't important */
    { "\0\014", 0, 0 },
        /* clrseq */

    /* clr_screen, clr_head, clr_tail PROCEDURES */
    /* I assume hardware support for clear screen at least */
    clrs1, clrh0, clrt0,

    /* inspace, makespace, rubout, erase STRINGS */
    /* inspace puts a space and moves the cursor right,
     * makespace doesn't move it. Likewise rubout moves the
     * cursor left, erase doesn't move it
     */
    { 0, 0, 0, 0 },
        /* charseq */

    /* ins_char, del_char PROCEDURES */
    /* insc1 uses inspace, insc2 makespace */
    /* delc1 uses rubout, delc2 erase */
    /* insc0, delc0 use neither */
    insc0, delc0,

    /* bright, normal STRINGS */
    { 0, 0 },
        /* vidseq */

    /* in_two, out_two PROCEDURES */
    sjs_intwo, sjs_outtwo,

    /* move PROCEDURE and nmove integer */
    sjs_move, 4,

    /* setup, special, pad PROCEDURES */
   sjs_setup, no_int, sjs_pad

 };
