diff -crN pc1450/Makefile pc126x/Makefile *** pc1450/Makefile Sat Oct 15 17:30:44 2016 --- pc126x/Makefile Sat Jan 30 05:13:33 2016 *************** *** 1,6 **** #CC=/usr/local/bin/gcc CC=cc ! CFLAGS= # implicit rules .c.o: $(CC) $(CFLAGS) -c $< --- 1,6 ---- #CC=/usr/local/bin/gcc CC=cc ! CFLAGS=-m32 # implicit rules .c.o: $(CC) $(CFLAGS) -c $< *************** *** 12,21 **** SRCS=pocket.c sc.c displcd.c key.c ttyin.c MAKEFILE=Makefile ! README=readme.txt $(PROG): $(OBJS) ! $(CC) -o $(PROG) $(OBJS) $(OBJS): $(HDRS) $(MAKEFILE) --- 12,22 ---- SRCS=pocket.c sc.c displcd.c key.c ttyin.c MAKEFILE=Makefile ! PCCORE=pc1450.bin ! SAMPLES=samples/* $(PROG): $(OBJS) ! $(CC) -m32 -o $(PROG) $(OBJS) $(OBJS): $(HDRS) $(MAKEFILE) *************** *** 23,28 **** rm -f $(OBJS) archive: ! tar cf - $(MAKEFILE) $(HDRS) $(SRCS) $(README) | gzip > pocket.tgz ! # EOF --- 24,30 ---- rm -f $(OBJS) archive: ! tar cf - $(MAKEFILE) $(HDRS) $(SRCS) | gzip > pocket.tgz ! lzh: ! lha a pocket.lzh $(MAKEFILE) $(HDRS) $(SRCS) diff -crN pc1450/displcd.c pc126x/displcd.c *** pc1450/displcd.c Tue Oct 3 00:55:42 1995 --- pc126x/displcd.c Sun Jan 17 04:23:56 2016 *************** *** 10,56 **** #define LCDX1 (5 * 12) #define LCDX2 (5 * 16) ! #define LCD1 0x7000 ! #define LCD2 0x703c ! #define LCD3 0x7068 ! #define LCD4 0x707c ! #define XMAX 80 ! #define log2phy(x) ((x) + (x) / 5) ! /* アドレスからx座標に変換 */ ! #define add2x(a) \ ! (((a) < LCD2) ? ((a) - LCD1) : (LCD4 - 1 - (a) + 60)) ! /* x座標からアドレスに変換 */ ! #define x2add(x) \ ! (((x) < (LCD2 - LCD1)) ? ((x) + LCD1) : (LCD4 - (x) + LCD1 - LCD2)) ! #define showbyadd(a) {int x; x = add2x(a); showone(log2phy(x), mainram[a]);} ! static int a2x[100]; ! static int x2a[100]; lcdinit() { int x; ! /* x座標とメモリアドレスの対応表の作成 */ ! for (x = 0; x < LCDX1; x++) { x2a[x] = LCD1 + x; } ! for (x = LCDX1; x < LCDX2; x++) { ! x2a[x] = LCD3 + (LCDX2 - x - 1); } } ! char *sym1[] = {"KANA", "S/K", "SML", "STAT"}; ! char *sym2[] = {"BUSY", "DEF", "SHIFT", "HYP", "PRO", "RUN", "CAL"}; ! char *sym3[] = {"E", "M", "()", "RAD", "G", "DE", "PRINT"}; ! #define SYM1 0x703c ! #define SYM2 0x703d ! #define SYM3 0x707c void symdisp() { --- 10,60 ---- #define LCDX1 (5 * 12) #define LCDX2 (5 * 16) ! #define LCD1 0x2000 ! #define LCD2 0x2800 ! #define LCD3 0x2040 ! #define LCD4 0x2840 ! #define XMAX 240 ! //#define log2phy(x) ((x) + (x) / 5) ! /* ≪鴻x綺ф紊 */ ! //#define add2x(a) \ ! // (((a) < LCD2) ? ((a) - LCD1) : (LCD4 - 1 - (a) + 60)) ! /* x綺ф≪鴻紊 */ ! //#define x2add(x) \ ! // (((x) < (LCD2 - LCD1)) ? ((x) + LCD1) : (LCD4 - (x) + LCD1 - LCD2)) ! //#define showbyadd(a) {int x; x = add2x(a); showone(log2phy(x), mainram[a]);} ! static int a2x[300]; ! static int x2a[300]; lcdinit() { int x; ! /* x綺ф<≪≪鴻絲上茵篏 */ ! for (x = 60*0; x < 60*1; x++) { x2a[x] = LCD1 + x; } ! for (x = 60*1; x < 60*2; x++) { ! x2a[x] = LCD2 + x - 60*1; ! } ! for (x = 60*2; x < 60*3; x++) { ! x2a[x] = LCD3 + x - 60*2; ! } ! for (x = 60*3; x < 60*4; x++) { ! x2a[x] = LCD4 + x - 60*3; } } ! char *sym1[] = {"BUSY", "PRINT", "", "", "SMALL", "SHIFT", "DEF", ""}; ! char *sym2[] = {"DEG", "RAD", "", "", "", "ERROR", "", ""}; ! #define SYM1 0x203d ! #define SYM2 0x207c void symdisp() { *************** *** 61,80 **** printf("%-5s ", (mainram[SYM2] & j) ? sym2[i] : ""); j *= 2; } j = 1; ! for (i = 0; i < 4; i++) { printf("%-4s ", (mainram[SYM1] & j) ? sym1[i] : ""); j *= 2; } ! j = 1; ! for (i = 0; i < 3; i++) { ! printf("%-3s ", (mainram[SYM3] & j) ? sym3[i] : ""); ! j *= 2; ! } ! printf("%-2s", (mainram[SYM3] & 0x20) ? sym3[5] : ""); ! printf("%-1s", (mainram[SYM3] & 0x10) ? sym3[4] : ""); ! printf("%-3s ", (mainram[SYM3] & 0x08) ? sym3[3] : ""); ! printf("%-5s\r\n", (mainram[SYM3] & 0x40) ? sym3[6] : ""); } --- 65,79 ---- printf("%-5s ", (mainram[SYM2] & j) ? sym2[i] : ""); j *= 2; } + putchar('\r'); + putchar('\n'); j = 1; ! for (i = 0; i < 7; i++) { printf("%-4s ", (mainram[SYM1] & j) ? sym1[i] : ""); j *= 2; } ! putchar('\r'); ! putchar('\n'); } *************** *** 92,98 **** printf(CURHOME); symdisp(); for (b = 1; b < 0x80; b *= 2) { ! for (x = 0; x < XMAX; x++) { if ((mainram[x2a[x]] & b) != 0) { putchar('#'); } --- 91,112 ---- printf(CURHOME); symdisp(); for (b = 1; b < 0x80; b *= 2) { ! for (x = 0; x < 120; x++) { ! if ((mainram[x2a[x]] & b) != 0) { ! putchar('#'); ! } ! else { ! putchar('.'); ! } ! if (x % 5 == 4) { ! putchar(' '); ! } ! } ! putchar('\r'); ! putchar('\n'); ! } ! for (b = 1; b < 0x80; b *= 2) { ! for (x = 120; x < 240; x++) { if ((mainram[x2a[x]] & b) != 0) { putchar('#'); } diff -crN pc1450/key.c pc126x/key.c *** pc1450/key.c Thu May 1 09:54:37 2014 --- pc126x/key.c Sat Oct 7 21:49:22 2017 *************** *** 3,13 **** #include #include ! unsigned char keym[100]; unsigned char kon=0; ! unsigned kbdpowoff; #define YES 1 #define NO 0 --- 3,13 ---- #include #include ! #include "pocket.h" unsigned char keym[100]; unsigned char kon=0; ! unsigned char kbdpowoff; #define YES 1 #define NO 0 *************** *** 33,40 **** #define NUL 0xff #define KEOF 0x04 static char scandef[] = { ! /* +0 +1 +2 +3 +4 +5 +6 +7 */ '7', '8', '9', '/', '>', NUL, NUL, NUL, '4', '5', '6', '*', '<', 'U', 'D', 'M', '1', '2', '3', '-', 'P', 'q', 'a', 'z', --- 33,41 ---- #define NUL 0xff #define KEOF 0x04 + /* static char scandef[] = { ! // +0 +1 +2 +3 +4 +5 +6 +7 '7', '8', '9', '/', '>', NUL, NUL, NUL, '4', '5', '6', '*', '<', 'U', 'D', 'M', '1', '2', '3', '-', 'P', 'q', 'a', 'z', *************** *** 42,56 **** 'H', 'S', 'C', 'T', 'K', 'e', 'd', 'c', 'X', 'G', 'N', 'L', '[', 'r', 'f', 'v', 'E', '^', 'R', 'Q', '\\', 't', 'g', 'b', ! NUL, CLR, '|', 'F', DN, 'y', 'h', 'n', ! NUL, NUL, ')', 'I', UP, 'u', 'j', 'm', ! NUL, NUL, NUL, '(', LA, 'i', 'k', ' ', ! NUL, NUL, NUL, NUL, RA, 'o', 'l', RET, NUL, NUL, NUL, NUL, NUL, 'p', ',', 'B', NUL, NUL, NUL, NUL, NUL, NUL, 'Z', 'A', NUL, NUL, NUL, NUL, NUL, NUL, NUL, KEOF }; int keyscan(ch) int ch; { --- 43,114 ---- 'H', 'S', 'C', 'T', 'K', 'e', 'd', 'c', 'X', 'G', 'N', 'L', '[', 'r', 'f', 'v', 'E', '^', 'R', 'Q', '\\', 't', 'g', 'b', ! NUL, CLR, '|', 'F', DN, 'y', 'h', 'n', ! NUL, NUL, ')', 'I', UP, 'u', 'j', 'm', ! NUL, NUL, NUL, '(', LA, 'i', 'k', ' ', ! NUL, NUL, NUL, NUL, RA, 'o', 'l', RET, NUL, NUL, NUL, NUL, NUL, 'p', ',', 'B', NUL, NUL, NUL, NUL, NUL, NUL, 'Z', 'A', NUL, NUL, NUL, NUL, NUL, NUL, NUL, KEOF }; + */ + static char scandef[] = { + /* +0 +1 +2 +3 +4 +5 +6 +7 */ + '-', CLR, '*', '/', DN, 'e', 'd', 'c', + '+', '9', '3', '6', ';', 'w', 's', 'x', + '.', '8', '2', '5', 'D', 'q', 'a', 'z', + NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, + NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, + NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, + NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, + NUL, '7', '1', '4', UP, 'r', 'f', 'v', + NUL, NUL, '=', 'p', LA, 't', 'g', 'b', + NUL, NUL, NUL, 'o', RA, 'y', 'h', 'n', + NUL, NUL, NUL, NUL, NUL, 'u', 'j', 'm', + NUL, NUL, NUL, NUL, NUL, 'i', 'k', ' ', + NUL, NUL, NUL, NUL, NUL, NUL, 'l', RET, + NUL, NUL, NUL, NUL, NUL, NUL, NUL, '0', + NUL, NUL, NUL, NUL, NUL, NUL, NUL, KEOF + }; + void load(){ + unsigned char lc3[65536]; + int size = 0x902; + FILE *fp; + int x, y; + + if ((fp = fopen("LC-3.bin", "r")) == NULL) { + fprintf(stderr, "LC-3.bin: can't open\n"); + exit(1); + } + if (fread(lc3, 1, size, fp) < size) { + fprintf(stderr, "LC-3.bin: read failed\n"); + exit(1); + } + fclose(fp); + for (x = 0; x < size; x++) { + mainram[x+0x4000] = lc3[x]; + } + } + void load_okuya(){ + unsigned char okuya[65536]; + int size = 0x64b0-0x5e00+1; + FILE *fp; + int x, y; + + if ((fp = fopen("okuya126.bin", "r")) == NULL) { + fprintf(stderr, "okuya126.bin: can't open\n"); + exit(1); + } + if (fread(okuya, 1, size, fp) < size) { + fprintf(stderr, "okuya126.bin: read failed\n"); + exit(1); + } + fclose(fp); + for (x = 0; x < size; x++) { + mainram[x+0x5e00] = okuya[x]; + } + } int keyscan(ch) int ch; { *************** *** 77,82 **** --- 135,152 ---- if (ch == KEOF) { kbdpowoff = YES; } + if (ch == 'R'){ + keym[99] = 0x00; + } + if (ch == 'P'){ + keym[99] = 0x02; + } + if (ch == 'V'){ + keym[99] = 0x01; + } + if (ch == 'L'){ + load(); + } return(ch); } *************** *** 106,108 **** --- 176,179 ---- printf("POWER OFF -> ^D\r\n"); } + diff -crN pc1450/pocket.c pc126x/pocket.c *** pc1450/pocket.c Fri Oct 14 12:40:57 2016 --- pc126x/pocket.c Mon Jan 25 14:58:16 2016 *************** *** 11,61 **** #define NOAUTOPOWOFF #define KBDEOF '\004' ! #define CPUROM "cpu-1450.rom" ! #define CPUADR 0x0000 ! #define CPUROMSIZ 0x2000 ! #define BASROM "bas-1450.rom" ! #define BASADR 0x8000 ! #define BASROMSIZ 0x8000 ! #define CORESIZE 65536 /*extern unsigned char *mainram;*/ unsigned char mainram[CORESIZE]; - main() { FILE *fp; int x, y, ch, k; int lastdisp; ! for (x = 0x2000; x < 0x8000; x++) { ! mainram[x] = 0; ! } ! if ((fp = fopen(CPUROM, "r")) == NULL) { ! fprintf(stderr, "%s: can't open\n", CPUROM); ! exit(1); ! } ! if (fread(&mainram[CPUADR], 1, CPUROMSIZ, fp) < CPUROMSIZ) { ! fprintf(stderr, "%s: read failed\n", CPUROM); ! exit(1); ! } ! if ((fp = fopen(BASROM, "r")) == NULL) { ! fprintf(stderr, "%s: can't open\n", BASROM); exit(1); } ! if (fread(&mainram[BASADR], 1, BASROMSIZ, fp) < BASROMSIZ) { ! fprintf(stderr, "%s: read failed\n", BASROM); exit(1); } fclose(fp); lcdinit(); kbdinit(); initsc(); clearall(); displayall(); scstatus(); ! showkeytab(); x = k = 0; lastdisp = disp_on; ch = -1; --- 11,49 ---- #define NOAUTOPOWOFF #define KBDEOF '\004' ! #define COREFILE "pc126x.bin" #define CORESIZE 65536 + /*extern unsigned char *mainram;*/ unsigned char mainram[CORESIZE]; main() { FILE *fp; int x, y, ch, k; int lastdisp; ! if ((fp = fopen(COREFILE, "r")) == NULL) { ! fprintf(stderr, "%s: can't open\n", COREFILE); exit(1); } ! if (fread(mainram, 1, CORESIZE, fp) < CORESIZE) { ! fprintf(stderr, "%s: read failed\n", COREFILE); exit(1); } fclose(fp); + for (x = 0x2000; x < 0x8000; x++) { + mainram[x] = 0; + } lcdinit(); kbdinit(); initsc(); clearall(); displayall(); + fprintf(stderr, "PC P Q R DP "); + fprintf(stderr, "I J A B XL XH YL YH K L M N C Z Pow kb I/O\r\n"); scstatus(); ! //showkeytab(); x = k = 0; lastdisp = disp_on; ch = -1; *************** *** 69,75 **** y = interpret(); #ifdef LOGFILE fprintf(fp, "%04x\n", y); ! #endif #if 0 ++k; if ((k > 100) && ((ch = getkey()) > 0)) { --- 57,63 ---- y = interpret(); #ifdef LOGFILE fprintf(fp, "%04x\n", y); ! #endif #if 0 ++k; if ((k > 100) && ((ch = getkey()) > 0)) { diff -crN pc1450/readme.txt pc126x/readme.txt *** pc1450/readme.txt Sat Oct 15 17:54:39 2016 --- pc126x/readme.txt Thu Jan 1 09:00:00 1970 *************** *** 1,66 **** - /* POCKET -- SHARP PORTABLE COMPUTER PC-1450 エミュレータ */ - - 【概要】 - UN*X系OS (FreeBSD, Linux, MacOS X, etc.) で動作する - ポケットコンピュータPC-1450のエミュレータです。 - - 【動作環境】 - UN*X系OSで動くはずです。 - 画面サイズ96x24のANSI (VT100) 互換ターミナルでの実行を推奨します。 - - 【追加で必要なファイル】 - SC61860の内部ROMイメージを実機から取得して「cpu-1450.rom」として - 保存しておいてください。外部ROMイメージも同様に採取のうえ - 「bas-1450.rom」というファイル名で保存してください。 - 実行時のカレントディレクトリにこれらの2つのファイルが必要です。 - - 【コンパイルおよび実行】 - 必要に応じてMakefileを編集します。たとえば、以下のとおり。 - % vi Makefile - make(1) コマンドでバイナリを生成します。 - % make - 生成された「pocket」が実行ファイルです。以下のように起動します。 - % ./pocket - - 【エミュレータの終了方法】 - ctrl-dの入力で終了します。 - - 【実機との相違】 - カセットテープやプリンタなどのI/Oは使えません。 - シリアルインターフェイスは、入力が sc.inp、出力が sc.out という - ファイルにそれぞれ対応します。 - インターフェイスを「OPEN」命令で初期化しておけば、 - 「LOAD」や「SAVE」でプログラムを読み書きすることができます。 - エミュレーションの速度は実行環境に依存します。 - 音は出ません。 - - 【キーの割り当て】 - ^d (ctrl-d) は POWER スイッチを OFF にすることに対応します。 - (つまり pocket を終了します。) - [ 0-9a-z] は、そのまま [ 0-9A-Z] に対応します。 - +, -, *, / も、そのまま +, -, *, / に対応します。 - ^n, ^p, ^b, ^f はカーソル移動キーに対応します。 - ^c は BRK, ^l は C/CE, ^m は ENTERキーに対応します。 - 大文字アルファベットは特殊キーに対応します。 - - 【キーの対応表】 - H → hyp S → sin C → cos T → tan F → F<->E - X → HEX G → DEG N → ln L → log I → 1/x | → STAT - E → EXP ^ → x^y R → SQRT Q → x^2 ( → ( ) → ) - > → x->M < → RM P → M+ % → +/- . → . = → = - A → CAL B → BASIC Z → SHIFT D → DEF M → SML U → SHIFT - K → カナ [ → ゛ \ → ー - - 【操作例】 - % make コンパイル - % pocket 実行 - 3 0 S sin(30) を計算します [ 3 0 sin ] - 6 9 U ) 69の階乗を計算します [ 6 9 SHIFT ) ] - B RUNモードに移行します [ BASIC ] - o p e n ^M - l o a d ^M sc.inp を BASICプログラムとしてロードします - r u n ^M プログラムを実行します - - 【参考文献】 - 1. 「I/O別冊 ポケコン・マシン語入門」(1984/09, 工学社) - 2. 「シャープポケットコンピュータ機械語マニュアル」(1986/05, 工学社) --- 0 ---- diff -crN pc1450/sc.c pc126x/sc.c *** pc1450/sc.c Wed Feb 24 20:38:36 2016 --- pc126x/sc.c Sat Jan 30 05:09:29 2016 *************** *** 72,79 **** #define ESCAPE 0x3f #define RTN 0x37 ! #define KEY_RELEASE 100000 /* 100,000 [us] -> 100 [ms] -> 1/10 [sec] */ ! #define KEY_WAIT 10000 /* 10,000 [us] -> 10 [ms] -> 1/100 [sec] */ #ifdef FREQ static unsigned int opfreq[256]; --- 72,83 ---- #define ESCAPE 0x3f #define RTN 0x37 ! //#define KEY_RELEASE 100000 /* 100,000 [us] -> 100 [ms] -> 1/10 [sec] */ ! //#define KEY_WAIT 10000 /* 10,000 [us] -> 10 [ms] -> 1/100 [sec] */ ! ! #define KEY_RELEASE 10000 /* 100,000 [us] -> 100 [ms] -> 1/10 [sec] */ ! #define KEY_WAIT 1000 /* 10,000 [us] -> 10 [ms] -> 1/100 [sec] */ ! #ifdef FREQ static unsigned int opfreq[256]; *************** *** 95,101 **** mainram[adr] = dat; } else { ! fprintf(stderr, "???\n"); power_on = NO; } /* if (a & 0x7000 == 0x7000) { --- 99,105 ---- mainram[adr] = dat; } else { ! fprintf(stderr, "???:%04x PC:%04x OP:%02x\n", adr, pc, opcode); power_on = NO; } /* if (a & 0x7000 == 0x7000) { *************** *** 145,156 **** static void mvmp() /* 54 */ { ! iram[preg] = mainram[pc]; } static void ldpc() /* 56 */ { ! areg = mainram[pc]; } static void sz() /* D7 */ --- 149,162 ---- static void mvmp() /* 54 */ { ! iram[preg] = mainram[pc]; ! // iram[preg] = mainram[pc+1]; // fixed by chame } static void ldpc() /* 56 */ { ! areg = mainram[pc]; ! // areg = mainram[pc+1]; // fixed by chame } static void sz() /* D7 */ *************** *** 686,693 **** xx = iram[preg] | (iram[preg + 1] << 8); xx += bareg; iram[preg] = xx; ! iram[++preg] = xx >> 8; ! zflag = (xx & 0x0000ffffL) == 0; cflag = (xx & 0xffff0000L) != 0; } --- 692,701 ---- xx = iram[preg] | (iram[preg + 1] << 8); xx += bareg; iram[preg] = xx; ! // iram[++preg] = xx >> 8; ! iram[preg + 1] = xx >> 8; // fixed by chame ! ! zflag = (xx & 0x0000ffffL) == 0; cflag = (xx & 0xffff0000L) != 0; } *************** *** 698,704 **** xx = iram[preg] | (iram[preg + 1] << 8); xx -= bareg; iram[preg] = xx; ! iram[++preg] = xx >> 8; zflag = (xx & 0x0000ffffL) == 0; cflag = (xx & 0xffff0000L) != 0; } --- 706,713 ---- xx = iram[preg] | (iram[preg + 1] << 8); xx -= bareg; iram[preg] = xx; ! // iram[++preg] = xx >> 8; ! iram[preg + 1] = xx >> 8; // fixed by chame zflag = (xx & 0x0000ffffL) == 0; cflag = (xx & 0xffff0000L) != 0; } *************** *** 1105,1143 **** lastscan.tv_sec = lastscan.tv_usec = 0; now.tv_sec = now.tv_usec = 0; if ((iaport != 0) && (ia == 0)) { ! ++cnt; ! if (cnt > 2) { ! keychar = ch = ttyin(KEY_WAIT); ! if (ch > 0) { ! keyscan(ch); ! gettimeofday(&lastscan, NULL); ! } ! else { ! gettimeofday(&now, NULL); ! interval ! = 1000000 * (now.tv_sec - lastscan.tv_sec) ! + now.tv_usec - lastscan.tv_usec; ! if (interval > KEY_RELEASE) { ! keyscan(0); } - } - cnt = 0; } - } - #if 0 - if (power_on) { - ch = getkey(); - } - else { - ch = getchar(); - } - if (ch > 0) { - keyscan(ch); - } - else { - keyscan(0); - } - #endif qreg= 0x5c; iaport = ia; } --- 1114,1137 ---- lastscan.tv_sec = lastscan.tv_usec = 0; now.tv_sec = now.tv_usec = 0; if ((iaport != 0) && (ia == 0)) { ! ++cnt; ! if (cnt > 2) { ! keychar = ch = ttyin(KEY_WAIT); ! if (ch > 0) { ! keyscan(ch); ! gettimeofday(&lastscan, NULL); ! } else { ! gettimeofday(&now, NULL); ! interval ! = 1000000 * (now.tv_sec - lastscan.tv_sec) ! + now.tv_usec - lastscan.tv_usec; ! if (interval > KEY_RELEASE) { ! keyscan(0); ! } ! } ! cnt = 0; } } qreg= 0x5c; iaport = ia; } *************** *** 1183,1209 **** static void ina() { int ii, jj, kk; areg = 0; ! if ((iaport == 0) && (mainram[0x7e00] != 0)) { ! jj = bit(mainram[0x7e00]); ! if (jj < 7) { ! areg = keym[jj]; ! } ! } ! else { ! jj = bit(iaport); ! if (jj < 7) { ! areg = keym[jj + 7]; ! } } zflag = (areg == 0); } static void inb() { ! areg = 0x38; zflag = (areg == 0); } --- 1177,1217 ---- static void ina() { + // fprintf(stderr, "iaport %02x,ibport %02x\n", iaport, ibport); int ii, jj, kk; areg = 0; ! if (ibport != 0) { ! jj = bit(ibport); ! areg = keym[jj]; ! } else { ! jj = bit(iaport); ! areg = keym[jj + 7]; } zflag = (areg == 0); } static void inb() { ! unsigned char ii = bit(ibport); ! unsigned char data= ii & 0x0f; ! unsigned char retval = 0; ! ! if (ii&8) ! { ! switch (keym[99]) ! { ! case 0x02 : retval|=2; break; ! case 0x01 : retval|=1; break; ! } ! } ! ! if ( (ii&2) && (keym[99]==0x02)) retval|=8; ! if ( (ii&1) && (keym[99]==0x02)) retval|=8; ! ! areg = (retval & ~data) | (ii & 0xf0); ! ! //areg = 0x38; zflag = (areg == 0); } *************** *** 1380,1385 **** --- 1388,1394 ---- int interpret() { tictac(); + scerr(); opcode = mainram[pc++]; #ifdef FREQ ++opfreq[opcode]; *************** *** 1403,1408 **** --- 1412,1418 ---- power_on = YES; kon = 0; iaport = ibport = foport = 0; + /* mainram[0xed34] = ESCAPE; mainram[0xed35] = BYTEOUT; mainram[0xed36] = 0x37; *************** *** 1411,1416 **** --- 1421,1427 ---- mainram[0xec30] = 0x37; mainram[0xeaa8] = 0xd0; mainram[0xeaa9] = 0x37; + */ #ifdef FREQ { int i; *************** *** 1434,1439 **** --- 1445,1460 ---- #endif } + scerr(){ + int xx; + if((pc >= 0x4000 && pc <= 0x4fff)){ // ||(pc >= 0x0222 && pc <= 0x0245) + fprintf(stderr, "%04x %02x %02x %02x %04x ", pc, preg, qreg, rreg, dp); + for (xx = 0; xx < 12; xx++) { + fprintf(stderr, "%02x ", iram[xx]); + } + fprintf(stderr, " %2x %2x\n", cflag, zflag); + } + } scstatus() { *************** *** 1460,1485 **** printf("%c", (('!' <= iochar) && (iochar <= '~')) ? iochar : '.'); putchar('\r'); putchar('\n'); ! printf("disp buf: "); ! for (xx = 0x70a9; xx < 0x70b9; xx++) { ! if ((' ' <= mainram[xx]) && (mainram[xx] <= '~')) { ! printf("%c", mainram[xx]); ! } ! else { ! printf("."); ! } ! } ! printf("\r\nMAINRAM 5ff0: "); ! for (xx = 0x5ff0; xx <= 0x6000; xx++) { ! printf("%02x ", mainram[xx]); ! } ! printf("\r\n IRAM 0010: "); ! for (xx = 0x10; xx <= 0x20; xx++) { ! printf("%02x ", iram[xx]); ! } ! printf("\r\n IRAM 0020: "); ! for (xx = 0x20; xx <= 0x30; xx++) { ! printf("%02x ", iram[xx]); ! } ! printf("\r\n"); } --- 1481,1488 ---- printf("%c", (('!' <= iochar) && (iochar <= '~')) ? iochar : '.'); putchar('\r'); putchar('\n'); ! printf("iaport %02x ", iaport); ! printf("ibport %02x ", ibport); ! putchar('\r'); ! putchar('\n'); } diff -crN pc1450/ttyin.c pc126x/ttyin.c *** pc1450/ttyin.c Thu May 1 11:52:42 2014 --- pc126x/ttyin.c Mon Jan 18 08:18:15 2016 *************** *** 79,87 **** /* 入力あり */ n = read(fileno(stdin), &buf[0], 1); if (n > 0) { ! fprintf(stderr, CURHOME); ! fprintf(stderr, "%c", ch); ! fflush(stderr); ch = buf[0]; } } --- 79,87 ---- /* 入力あり */ n = read(fileno(stdin), &buf[0], 1); if (n > 0) { ! // fprintf(stderr, CURHOME); ! // fprintf(stderr, "%c", ch); ! // fflush(stderr); ch = buf[0]; } }