#include #include #include #include #include #include #define PAR1 0x378 #define PAR2 0x379 #define PAR3 0x37a #define DELAY1 32000 int main(){ FILE *fp; unsigned int inb; char c; int i,j,pcount; unsigned int hextowrite; unsigned char mem[2048],p1,p2,ti,lo1,rho1,ho1,accumulator; pcount=0; (void) initscr(); /* initialize the curses library */ keypad(stdscr, TRUE); /* enable keyboard mapping */ (void) nonl(); /* tell curses not to do NL->CR/NL on output */ (void) cbreak(); /* take input chars one at a time, no wait for \n */ (void) noecho(); /* don't echo input */ if((fp=fopen("mem","r")) == NULL){ printf("cannot open file\n"); endwin(); exit(1); } for(i=0;i<2048;i++){ mem[i]=getc(fp); } fclose(fp); for(i=0;i<7;i++){ mvprintw(0,24+i*8,"Mem OC"); } mvprintw(4,0,"Accumulator:"); mvprintw(6,6,"Port1:"); mvprintw(8,6,"Port2:"); resetcpu(); while(pcount<0x1ff){ stat(&ti,&p1,&p2,&pcount); for(i=0;i<23;i++){ for(j=0;j<7;j++){ mvprintw(1+i,24+j*8,"%03x:%02x",i+j*23,mem[i+j*23]); if(pcount==i+j*23) mvaddch(i+1,23+j*8,'*'); else mvaddch(i+1,23+j*8,' '); } } get_accumulator(&accumulator,pcount); mvprintw(4,13,"%02x",accumulator); mvprintw(6,13,"%02x",p1); mvprintw(8,13,"%02x",p2); out1 (mem[pcount+1]); delay(); latchnext(); out1(mem[pcount]); delay(); out3(0); delay(); out3(8); move(0,0); refresh(); } for (;;){ } endwin(); } int get_accumulator(unsigned char *accumulator,int count){ unsigned char counttriml,counttrimh,alo,ahi; counttriml=count & 0x0000ff; counttrimh=(count >> 8) & 0x00000f; out3 (8); delay(); out1(0x90); delay(); out3 (0); delay(); out3 (8); delay(); out3(0xf); delay(); alo=in2(); delay(); out1(0x47); delay(); out3 (0); delay(); out3 (8); delay(); out1(0x90); delay(); out3 (0); delay(); out3 (8); delay(); out3(0xf); delay(); ahi=in2(); delay(); out1(0x47); delay(); out3 (0); delay(); out3 (8); delay(); *accumulator=ahi*16+alo; out1 (counttriml); delay(); latchnext(); out1(counttrimh << 5 | 04); delay(); out3 (0); delay(); out3 (8); delay(); } int delay () { int i; for(i=1;i