From billh@comtch.iea.com Thu Jan 20 21:57:14 1994
Return-Path: <sac@cygnus.com>
Received: from relay1.UU.NET by comtch.iea.com with smtp
	(Smail3.1.28.1 #6) id m0pNDeC-0000xmC; Thu, 20 Jan 94 20:39 PST
Received: from cygnus.com by relay1.UU.NET with SMTP 
	(5.61/UUNET-internet-primary) id AAvzgl09566; Mon, 17 Jan 94 11:58:21 -0500
Received: from jonny.cygnus.com by cygnus.com (4.1/SMI-4.1)
	id AA12253; Mon, 17 Jan 94 08:58:12 PST
From: sac@cygnus.com (Steve Chamberlain)
Received: from localhost by jonny.cygnus.com (4.1/SMI-4.1)
	id AA27236; Mon, 17 Jan 94 08:51:38 PST
Message-Id: <9401171651.AA27236@jonny.cygnus.com>
To: comtch.iea.com!billh@cygnus.com (Bill Haygood)
Cc: sac@cygnus.com
>Subject: Re: Bill H's pdp8 emulator 
In-Reply-To: Your message of "Sun, 16 Jan 94 16:38:55 PST."
             <m0pLhzb-0005rVC@comtch.iea.com> 
Date: Mon, 17 Jan 94 08:51:38 -0800

> 
> 
> Steve,
> 
> Would you please send me a copy of the 'pdp8loc.c' file that you modified
> to run my emulator on your system ?
> 
> Thanks!
> 
> --Bill


Sure, the hack below works on my Sun.  I have been very busy recently, so haven't
had a chance to mess about.  The first thing I did was write a program to
generate the opr instruction code, since I was toying with the idea of
of running every ac+l pattern through all possible instructions to see if
there were any differences between the two.  There were differences.. There
was a bug in my C compiler!  That's been fixed but it still doesn't run too
well, and I've not had a chance to finish my work.





#include <stdio.h>
#include <sys/file.h>
#include <sys/fcntl.h>



#define BSIZE 256

static int fd;
static char buf[BSIZE];

static int buf_head;
static int buf_tail;


void
local_uninit ()
{
}

int
GetChar (io, clear)
int io;
int clear;
{
  int x = buf[buf_tail];
  if (buf_head != buf_tail)
    {
      if (clear)
	{
	  buf[buf_tail] = '*';
	  buf_tail++;
	  buf_tail &= BSIZE - 1;
	}
    }
  if (x == 10)
    return 13;
  return x;
}

void
PutChar (int dev, char x)
{
  char s[2];
  s[0] = x & 0x7f;
  s[1] = 0;
  write (fd, s, 1);
}

void
local_init ()
{
  int flags;
  fd = open ("/dev/tty", O_RDWR);
  flags = fcntl (fd, F_GETFL, 0);
  fcntl (fd, F_SETFL, (flags | O_NDELAY));
}

int
KeyStrike ()
{
  char lastchar;
  int x = read (fd, &lastchar, 1);
  if (x > 0)
    {
      buf[buf_head++] = lastchar & 0x7f;
      buf_head &= BSIZE - 1;
    }
  return buf_head != buf_tail;
}
